diff --git a/.github/workflows/ci-testing.yaml b/.github/workflows/ci-testing.yaml index 5905c0a..2b4d042 100644 --- a/.github/workflows/ci-testing.yaml +++ b/.github/workflows/ci-testing.yaml @@ -11,7 +11,7 @@ jobs: strategy: matrix: - python-version: ["3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v3 diff --git a/auraxium/_proxy.py b/auraxium/_proxy.py index c55163e..62d67ba 100644 --- a/auraxium/_proxy.py +++ b/auraxium/_proxy.py @@ -56,8 +56,10 @@ def __init__(self, type_: Type[_Ps2ObjectT], query: Query, self._data: List[_Ps2ObjectT] self._index: int self._lock = asyncio.Lock() - self._last_fetched = datetime.datetime.fromtimestamp(0, datetime.UTC) - max_age = datetime.datetime.now(datetime.UTC) - self._last_fetched + self._last_fetched = datetime.datetime.fromtimestamp( + 0, datetime.timezone.utc) + max_age = datetime.datetime.now( + datetime.timezone.utc) - self._last_fetched assert self._ttu < max_age.total_seconds() async def _poll(self) -> None: @@ -70,7 +72,7 @@ async def _poll(self) -> None: payload = await self._client.request(self.query) list_ = self._resolve_nested_payload(payload) self._data = [self._type(d, client=self._client) for d in list_] - self._last_fetched = datetime.datetime.now(datetime.UTC) + self._last_fetched = datetime.datetime.now(datetime.timezone.utc) def _resolve_nested_payload(self, payload: CensusData) -> List[CensusData]: """Resolve the object payload. @@ -143,7 +145,7 @@ def __aiter__(self) -> 'SequenceProxy[_Ps2ObjectT]': return self async def __anext__(self) -> _Ps2ObjectT: - age = datetime.datetime.now(datetime.UTC) - self._last_fetched + age = datetime.datetime.now(datetime.timezone.utc) - self._last_fetched if age.total_seconds() > self._ttu: if self._index > -1: warnings.warn('Data went stale during iteration, polling new') @@ -181,7 +183,7 @@ async def resolve(self) -> Optional[_Ps2ObjectT]: :return: The object, or :obj:`None` if no match was found. """ - age = datetime.datetime.now(datetime.UTC) - self._last_fetched + age = datetime.datetime.now(datetime.timezone.utc) - self._last_fetched if age.total_seconds() > self._ttu: await self._poll() try: diff --git a/auraxium/census/_support.py b/auraxium/census/_support.py index 56fb718..7b96637 100644 --- a/auraxium/census/_support.py +++ b/auraxium/census/_support.py @@ -34,7 +34,6 @@ class SearchModifier(enum.Enum): GREATER_THAN_OR_EQUAL: ']', STARTS_WITH: '^', CONTAINS: '*', NOT_EQUAL: '!' """ - # pylint: disable=invalid-name EQUAL_TO = 0 LESS_THAN = 1 @@ -45,77 +44,53 @@ class SearchModifier(enum.Enum): CONTAINS = 6 NOT_EQUAL = 7 - @classmethod - @property - def EQ(cls) -> 'SearchModifier': - """Alias for :class:`EQUAL_TO `. + EQ = EQUAL_TO + """Alias for :class:`EQUAL_TO `. - .. versionadded:: 0.2 - """ - return cls.EQUAL_TO + .. versionadded:: 0.2 + """ - @classmethod - @property - def LT(cls) -> 'SearchModifier': - """Alias for :class:`LESS_THAN `. + LT = LESS_THAN + """Alias for :class:`LESS_THAN `. - .. versionadded:: 0.2 - """ - return cls.LESS_THAN + .. versionadded:: 0.2 + """ - @classmethod - @property - def LTE(cls) -> 'SearchModifier': - """Alias for :class:`LESS_THAN_OR_EQUAL `. + LTE = LESS_THAN_OR_EQUAL + """Alias for :class:`LESS_THAN_OR_EQUAL `. - .. versionadded:: 0.2 - """ - return cls.LESS_THAN_OR_EQUAL + .. versionadded:: 0.2 + """ - @classmethod - @property - def GT(cls) -> 'SearchModifier': - """Alias for :class:`GREATER_THAN `. + GT = GREATER_THAN + """Alias for :class:`GREATER_THAN `. - .. versionadded:: 0.2 - """ - return cls.GREATER_THAN + .. versionadded:: 0.2 + """ - @classmethod - @property - def GTE(cls) -> 'SearchModifier': - """Alias for :class:`GREATER_THAN_OR_EQUAL `. + GTE = GREATER_THAN_OR_EQUAL + """Alias for :class:`GREATER_THAN_OR_EQUAL `. - .. versionadded:: 0.2 - """ - return cls.GREATER_THAN_OR_EQUAL + .. versionadded:: 0.2 + """ - @classmethod - @property - def SW(cls) -> 'SearchModifier': - """Alias for :class:`STARTS_WITH `. + SW = STARTS_WITH + """Alias for :class:`STARTS_WITH `. - .. versionadded:: 0.2 - """ - return cls.STARTS_WITH + .. versionadded:: 0.2 + """ - @classmethod - @property - def IN(cls) -> 'SearchModifier': - """Alias for :class:`CONTAINS `. + IN = CONTAINS + """Alias for :class:`CONTAINS `. - .. versionadded:: 0.2 - """ - return cls.CONTAINS + .. versionadded:: 0.2 + """ - @classmethod - @property - def NE(cls) -> 'SearchModifier': - """Alias for :class:`NOT_EQUAL `. + NE = NOT_EQUAL + """Alias for :class:`NOT_EQUAL `. - .. versionadded:: 0.2 - """ - return cls.NOT_EQUAL + .. versionadded:: 0.2 + """ @classmethod def from_value(cls, value: CensusValue) -> 'SearchModifier': diff --git a/auraxium/event/_trigger.py b/auraxium/event/_trigger.py index b0df411..5e678d7 100644 --- a/auraxium/event/_trigger.py +++ b/auraxium/event/_trigger.py @@ -226,7 +226,7 @@ async def run(self, event: Event) -> None: :param Event event: The event to pass to the trigger action. """ - self.last_run = datetime.datetime.now(datetime.UTC) + self.last_run = datetime.datetime.now(datetime.timezone.utc) if self.action is None: # pragma: no cover warnings.warn(f'Trigger {self.name} run with no action specified') return diff --git a/auraxium/models/base.py b/auraxium/models/base.py index d94c37f..e41d604 100644 --- a/auraxium/models/base.py +++ b/auraxium/models/base.py @@ -139,12 +139,12 @@ def _utc_from_timestamp(cls, value: str, ) -> datetime.datetime: """Convert timestamps to UTC datetimes.""" _ = info - return datetime.datetime.fromtimestamp(int(value), datetime.UTC) + return datetime.datetime.fromtimestamp(int(value), datetime.timezone.utc) @property def age(self) -> float: """The age of the event in seconds.""" - now = datetime.datetime.now(datetime.UTC) + now = datetime.datetime.now(datetime.timezone.utc) return (now - self.timestamp).total_seconds() diff --git a/auraxium/ps2/_world.py b/auraxium/ps2/_world.py index 400c52a..cacd2a7 100644 --- a/auraxium/ps2/_world.py +++ b/auraxium/ps2/_world.py @@ -122,4 +122,5 @@ async def status(self) -> Tuple[str, datetime.datetime]: data = extract_single(payload, 'game_server_status') status = str(data['last_reported_state']) last_updated = int(str(data['last_reported_time'])) - return status, datetime.datetime.utcfromtimestamp(last_updated) + return status, datetime.datetime.fromtimestamp( + last_updated, datetime.timezone.utc) diff --git a/tests/unit/trigger_test.py b/tests/unit/trigger_test.py index 05916a0..1b4ea59 100644 --- a/tests/unit/trigger_test.py +++ b/tests/unit/trigger_test.py @@ -11,7 +11,7 @@ class TriggerTest(unittest.TestCase): """Test cases for the auraxium.event.Trigger class.""" - time = datetime.datetime.utcnow() + time = datetime.datetime.now(datetime.timezone.utc) @classmethod def death_evt_factory(cls, attacker: int, victim: int, world: int,