Skip to content

Commit

Permalink
chore: Reformat files
Browse files Browse the repository at this point in the history
  • Loading branch information
malmeloo committed Sep 3, 2024
1 parent 239bc01 commit 1c18519
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 52 deletions.
2 changes: 2 additions & 0 deletions examples/_login.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# ruff: noqa: ASYNC230

import json
from pathlib import Path

Expand Down
1 change: 1 addition & 0 deletions examples/real_airtag.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Example showing how to fetch locations of an AirTag, or any other FindMy accessory.
"""

from __future__ import annotations

import logging
Expand Down
1 change: 1 addition & 0 deletions findmy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A package providing everything you need to work with Apple's FindMy network."""

from . import errors, keys, reports, scanner
from .accessory import FindMyAccessory
from .keys import KeyPair
Expand Down
9 changes: 4 additions & 5 deletions findmy/accessory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Accessories could be anything ranging from AirTags to iPhones.
"""

from __future__ import annotations

import logging
Expand Down Expand Up @@ -64,7 +65,7 @@ def keys_between(self, start: int | datetime, end: int | datetime) -> set[KeyPai
class FindMyAccessory(RollingKeyPairSource):
"""A findable Find My-accessory using official key rollover."""

def __init__( # noqa: PLR0913
def __init__(
self,
master_key: bytes,
skn: bytes,
Expand Down Expand Up @@ -235,12 +236,10 @@ def __next__(self) -> KeyPair:
return self._get_keypair(self._iter_ind)

@overload
def __getitem__(self, val: int) -> KeyPair:
...
def __getitem__(self, val: int) -> KeyPair: ...

@overload
def __getitem__(self, val: slice) -> Generator[KeyPair, None, None]:
...
def __getitem__(self, val: slice) -> Generator[KeyPair, None, None]: ...

@override
def __getitem__(self, val: int | slice) -> KeyPair | Generator[KeyPair, None, None]:
Expand Down
7 changes: 3 additions & 4 deletions findmy/keys.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module to work with private and public keys as used in FindMy accessories."""

from __future__ import annotations

import base64
Expand Down Expand Up @@ -156,13 +157,11 @@ def __next__(self) -> K:

@overload
@abstractmethod
def __getitem__(self, val: int) -> K:
...
def __getitem__(self, val: int) -> K: ...

@overload
@abstractmethod
def __getitem__(self, val: slice) -> Generator[K, None, None]:
...
def __getitem__(self, val: slice) -> Generator[K, None, None]: ...

@abstractmethod
def __getitem__(self, val: int | slice) -> K | Generator[K, None, None]:
Expand Down
1 change: 1 addition & 0 deletions findmy/reports/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Code related to fetching location reports."""

from .account import AppleAccount, AsyncAppleAccount
from .anisette import BaseAnisetteProvider, RemoteAnisetteProvider
from .state import LoginState
Expand Down
54 changes: 18 additions & 36 deletions findmy/reports/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,7 @@ def fetch_reports(
keys: HasHashedPublicKey,
date_from: datetime,
date_to: datetime | None,
) -> MaybeCoro[list[LocationReport]]:
...
) -> MaybeCoro[list[LocationReport]]: ...

@overload
@abstractmethod
Expand All @@ -238,8 +237,7 @@ def fetch_reports(
keys: Sequence[HasHashedPublicKey],
date_from: datetime,
date_to: datetime | None,
) -> MaybeCoro[dict[HasHashedPublicKey, list[LocationReport]]]:
...
) -> MaybeCoro[dict[HasHashedPublicKey, list[LocationReport]]]: ...

@overload
@abstractmethod
Expand All @@ -248,8 +246,7 @@ def fetch_reports(
keys: RollingKeyPairSource,
date_from: datetime,
date_to: datetime | None,
) -> MaybeCoro[list[LocationReport]]:
...
) -> MaybeCoro[list[LocationReport]]: ...

@abstractmethod
def fetch_reports(
Expand All @@ -271,26 +268,23 @@ def fetch_last_reports(
self,
keys: HasHashedPublicKey,
hours: int = 7 * 24,
) -> MaybeCoro[list[LocationReport]]:
...
) -> MaybeCoro[list[LocationReport]]: ...

@overload
@abstractmethod
def fetch_last_reports(
self,
keys: Sequence[HasHashedPublicKey],
hours: int = 7 * 24,
) -> MaybeCoro[dict[HasHashedPublicKey, list[LocationReport]]]:
...
) -> MaybeCoro[dict[HasHashedPublicKey, list[LocationReport]]]: ...

@overload
@abstractmethod
def fetch_last_reports(
self,
keys: RollingKeyPairSource,
hours: int = 7 * 24,
) -> MaybeCoro[list[LocationReport]]:
...
) -> MaybeCoro[list[LocationReport]]: ...

@abstractmethod
def fetch_last_reports(
Expand Down Expand Up @@ -629,26 +623,23 @@ async def fetch_reports(
keys: HasHashedPublicKey,
date_from: datetime,
date_to: datetime | None,
) -> list[LocationReport]:
...
) -> list[LocationReport]: ...

@overload
async def fetch_reports(
self,
keys: Sequence[HasHashedPublicKey],
date_from: datetime,
date_to: datetime | None,
) -> dict[HasHashedPublicKey, list[LocationReport]]:
...
) -> dict[HasHashedPublicKey, list[LocationReport]]: ...

@overload
async def fetch_reports(
self,
keys: RollingKeyPairSource,
date_from: datetime,
date_to: datetime | None,
) -> list[LocationReport]:
...
) -> list[LocationReport]: ...

@require_login_state(LoginState.LOGGED_IN)
@override
Expand All @@ -672,24 +663,21 @@ async def fetch_last_reports(
self,
keys: HasHashedPublicKey,
hours: int = 7 * 24,
) -> list[LocationReport]:
...
) -> list[LocationReport]: ...

@overload
async def fetch_last_reports(
self,
keys: Sequence[HasHashedPublicKey],
hours: int = 7 * 24,
) -> dict[HasHashedPublicKey, list[LocationReport]]:
...
) -> dict[HasHashedPublicKey, list[LocationReport]]: ...

@overload
async def fetch_last_reports(
self,
keys: RollingKeyPairSource,
hours: int = 7 * 24,
) -> list[LocationReport]:
...
) -> list[LocationReport]: ...

@require_login_state(LoginState.LOGGED_IN)
@override
Expand Down Expand Up @@ -1035,26 +1023,23 @@ def fetch_reports(
keys: HasHashedPublicKey,
date_from: datetime,
date_to: datetime | None,
) -> list[LocationReport]:
...
) -> list[LocationReport]: ...

@overload
def fetch_reports(
self,
keys: Sequence[HasHashedPublicKey],
date_from: datetime,
date_to: datetime | None,
) -> dict[HasHashedPublicKey, list[LocationReport]]:
...
) -> dict[HasHashedPublicKey, list[LocationReport]]: ...

@overload
def fetch_reports(
self,
keys: RollingKeyPairSource,
date_from: datetime,
date_to: datetime | None,
) -> list[LocationReport]:
...
) -> list[LocationReport]: ...

@override
def fetch_reports(
Expand All @@ -1072,24 +1057,21 @@ def fetch_last_reports(
self,
keys: HasHashedPublicKey,
hours: int = 7 * 24,
) -> list[LocationReport]:
...
) -> list[LocationReport]: ...

@overload
def fetch_last_reports(
self,
keys: Sequence[HasHashedPublicKey],
hours: int = 7 * 24,
) -> dict[HasHashedPublicKey, list[LocationReport]]:
...
) -> dict[HasHashedPublicKey, list[LocationReport]]: ...

@overload
def fetch_last_reports(
self,
keys: RollingKeyPairSource,
hours: int = 7 * 24,
) -> list[LocationReport]:
...
) -> list[LocationReport]: ...

@override
def fetch_last_reports(
Expand Down
1 change: 1 addition & 0 deletions findmy/reports/anisette.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module for Anisette header providers."""

from __future__ import annotations

import base64
Expand Down
9 changes: 3 additions & 6 deletions findmy/reports/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,26 +232,23 @@ async def fetch_reports(
date_from: datetime,
date_to: datetime,
device: HasHashedPublicKey,
) -> list[LocationReport]:
...
) -> list[LocationReport]: ...

@overload
async def fetch_reports(
self,
date_from: datetime,
date_to: datetime,
device: Sequence[HasHashedPublicKey],
) -> dict[HasHashedPublicKey, list[LocationReport]]:
...
) -> dict[HasHashedPublicKey, list[LocationReport]]: ...

@overload
async def fetch_reports(
self,
date_from: datetime,
date_to: datetime,
device: RollingKeyPairSource,
) -> list[LocationReport]:
...
) -> list[LocationReport]: ...

async def fetch_reports(
self,
Expand Down
1 change: 1 addition & 0 deletions findmy/reports/state.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Account login state."""

from enum import Enum

from typing_extensions import override
Expand Down
1 change: 1 addition & 0 deletions findmy/reports/twofactor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Public classes related to handling two-factor authentication."""

from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Generic, TypeVar

Expand Down
1 change: 1 addition & 0 deletions findmy/scanner/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities related to physically discoverable FindMy-devices."""

from .scanner import (
NearbyOfflineFindingDevice,
OfflineFindingScanner,
Expand Down
2 changes: 1 addition & 1 deletion findmy/scanner/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def payload_len(cls) -> int:
"""Length of OfflineFinding data payload in bytes."""
return 0x02 # 2

def __init__( # noqa: PLR0913
def __init__(
self,
mac_bytes: bytes,
status_byte: int,
Expand Down
1 change: 1 addition & 0 deletions findmy/util/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions and classes. Intended for internal use."""

from .http import HttpResponse, HttpSession
from .parsers import decode_plist

Expand Down
1 change: 1 addition & 0 deletions findmy/util/closable.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""ABC for async classes that need to be cleaned up before exiting."""

from __future__ import annotations

import asyncio
Expand Down
1 change: 1 addition & 0 deletions findmy/util/http.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module to simplify asynchronous HTTP calls."""

from __future__ import annotations

import json
Expand Down
1 change: 1 addition & 0 deletions findmy/util/parsers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Parsers for various forms of data formats."""

import plistlib
from typing import Any

Expand Down

0 comments on commit 1c18519

Please sign in to comment.