Skip to content

Commit

Permalink
Merge branch 'agronholm:master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu0629 authored Sep 22, 2024
2 parents 975a7d5 + 0bcb319 commit 7960ad1
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 56 deletions.
7 changes: 1 addition & 6 deletions src/apscheduler/_converters.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
from __future__ import annotations

import sys
from collections.abc import Callable
from datetime import date, datetime, timedelta, timezone
from typing import Any
from uuid import UUID
from zoneinfo import ZoneInfo

from tzlocal import get_localzone

if sys.version_info >= (3, 9):
from zoneinfo import ZoneInfo
else:
from backports.zoneinfo import ZoneInfo


def as_int(value: Any) -> Any:
if isinstance(value, str):
Expand Down
7 changes: 1 addition & 6 deletions src/apscheduler/_marshalling.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
from __future__ import annotations

import sys
from datetime import tzinfo
from functools import partial
from inspect import isclass, ismethod, ismethoddescriptor
from typing import Any, Callable
from zoneinfo import ZoneInfo

from ._exceptions import DeserializationError, SerializationError

if sys.version_info >= (3, 9):
from zoneinfo import ZoneInfo
else:
from backports.zoneinfo import ZoneInfo


def marshal_object(obj) -> tuple[str, Any]:
return (
Expand Down
4 changes: 2 additions & 2 deletions src/apscheduler/_schedulers/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import platform
import random
import sys
from collections.abc import MutableMapping, Sequence
from collections.abc import Iterable, Mapping, MutableMapping, Sequence
from contextlib import AsyncExitStack
from datetime import datetime, timedelta, timezone
from functools import partial
from inspect import isbuiltin, isclass, ismethod, ismodule
from logging import Logger, getLogger
from types import TracebackType
from typing import Any, Callable, Iterable, Literal, Mapping, TypeVar, cast, overload
from typing import Any, Callable, Literal, TypeVar, cast, overload
from uuid import UUID, uuid4

import anyio
Expand Down
4 changes: 2 additions & 2 deletions src/apscheduler/_schedulers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import atexit
import sys
import threading
from collections.abc import MutableMapping, Sequence
from collections.abc import Iterable, Mapping, MutableMapping, Sequence
from contextlib import ExitStack
from datetime import datetime, timedelta
from functools import partial
from logging import Logger
from types import TracebackType
from typing import Any, Callable, Iterable, Literal, Mapping, overload
from typing import Any, Callable, Literal, overload
from uuid import UUID

import attrs
Expand Down
7 changes: 1 addition & 6 deletions src/apscheduler/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@

from __future__ import annotations

import sys
from datetime import datetime, tzinfo
from typing import TYPE_CHECKING, Any, NoReturn, TypeVar
from zoneinfo import ZoneInfo

from ._exceptions import DeserializationError
from .abc import Trigger

if sys.version_info >= (3, 9):
from zoneinfo import ZoneInfo
else:
from backports.zoneinfo import ZoneInfo

if TYPE_CHECKING:
from ._structures import MetadataType

Expand Down
4 changes: 2 additions & 2 deletions src/apscheduler/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import sys
from abc import ABCMeta, abstractmethod
from collections.abc import Sequence
from collections.abc import Iterable, Iterator, Sequence
from contextlib import AsyncExitStack
from datetime import datetime, timedelta
from logging import Logger
from typing import TYPE_CHECKING, Any, Callable, Iterable, Iterator
from typing import TYPE_CHECKING, Any, Callable
from uuid import UUID

if sys.version_info >= (3, 11):
Expand Down
3 changes: 1 addition & 2 deletions src/apscheduler/datastores/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

from bisect import bisect_left, bisect_right, insort_right
from collections import defaultdict
from collections.abc import Sequence
from collections.abc import Iterable, Sequence
from datetime import MAXYEAR, datetime, timedelta, timezone
from functools import partial
from typing import Iterable
from uuid import UUID

import attrs
Expand Down
4 changes: 2 additions & 2 deletions src/apscheduler/datastores/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import operator
import sys
from collections.abc import AsyncGenerator, AsyncIterator, Sequence
from collections.abc import AsyncGenerator, AsyncIterator, Iterable, Mapping, Sequence
from contextlib import AsyncExitStack, asynccontextmanager
from datetime import datetime, timedelta, timezone
from logging import Logger
from typing import Any, Callable, ClassVar, Generic, Iterable, Mapping, TypeVar, cast
from typing import Any, Callable, ClassVar, Generic, TypeVar, cast
from uuid import UUID

import attrs
Expand Down
4 changes: 2 additions & 2 deletions src/apscheduler/datastores/sqlalchemy.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from __future__ import annotations

from collections import defaultdict
from collections.abc import AsyncGenerator, Mapping, Sequence
from collections.abc import AsyncGenerator, Iterable, Mapping, Sequence
from contextlib import AsyncExitStack, asynccontextmanager
from datetime import datetime, timedelta, timezone
from functools import partial
from logging import Logger
from typing import Any, Iterable, cast
from typing import Any, cast
from uuid import UUID

import anyio
Expand Down
3 changes: 2 additions & 1 deletion src/apscheduler/eventbrokers/base.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from __future__ import annotations

from base64 import b64decode, b64encode
from collections.abc import Iterable
from contextlib import AsyncExitStack
from inspect import iscoroutine
from logging import Logger
from typing import Any, Callable, Iterable
from typing import Any, Callable

import attrs
from anyio import CapacityLimiter, create_task_group, to_thread
Expand Down
3 changes: 2 additions & 1 deletion src/apscheduler/triggers/cron/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations

from collections.abc import Sequence
from datetime import datetime, timedelta, tzinfo
from typing import Any, ClassVar, Sequence
from typing import Any, ClassVar

import attrs
from attr.validators import instance_of, optional
Expand Down
3 changes: 2 additions & 1 deletion src/apscheduler/triggers/cron/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import re
from calendar import monthrange
from datetime import datetime
from typing import TYPE_CHECKING, ClassVar, Pattern
from re import Pattern
from typing import TYPE_CHECKING, ClassVar

import attrs
from attr.validators import instance_of, optional
Expand Down
4 changes: 2 additions & 2 deletions src/apscheduler/triggers/cron/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import re
from calendar import monthrange
from collections.abc import Mapping
from collections.abc import Mapping, Sequence
from datetime import datetime
from typing import Any, ClassVar, Sequence
from typing import Any, ClassVar

from .expressions import (
WEEKDAYS,
Expand Down
11 changes: 3 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from __future__ import annotations

import logging
import sys
from collections.abc import Generator
from collections.abc import AsyncGenerator, Generator
from contextlib import AsyncExitStack
from logging import Logger
from pathlib import Path
from typing import Any, AsyncGenerator, cast
from typing import Any, cast
from zoneinfo import ZoneInfo

import pytest
from _pytest.fixtures import SubRequest
Expand All @@ -18,11 +18,6 @@
from apscheduler.serializers.json import JSONSerializer
from apscheduler.serializers.pickle import PickleSerializer

if sys.version_info >= (3, 9):
from zoneinfo import ZoneInfo
else:
from backports.zoneinfo import ZoneInfo


@pytest.fixture(scope="session")
def timezone() -> ZoneInfo:
Expand Down
10 changes: 7 additions & 3 deletions tests/test_datastores.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from __future__ import annotations

import platform
from collections.abc import AsyncGenerator
from contextlib import AsyncExitStack, asynccontextmanager
from datetime import datetime, timedelta, timezone
from logging import Logger
from pathlib import Path
from typing import TYPE_CHECKING, AsyncGenerator
from typing import TYPE_CHECKING
from unittest.mock import Mock

import anyio
Expand Down Expand Up @@ -856,5 +857,8 @@ async def test_psycopg(self) -> None:
)

async def test_mongodb(self) -> None:
data_store = MongoDBDataStore("mongodb://localhost")
assert repr(data_store) == "MongoDBDataStore(host=[('localhost', 27017)])"
from pymongo import MongoClient

with MongoClient() as client:
data_store = MongoDBDataStore(client)
assert repr(data_store) == "MongoDBDataStore(host=[('localhost', 27017)])"
5 changes: 1 addition & 4 deletions tests/test_schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@
else:
UTC = timezone.utc

if sys.version_info >= (3, 9):
from zoneinfo import ZoneInfo
else:
from backports.zoneinfo import ZoneInfo
from zoneinfo import ZoneInfo

pytestmark = pytest.mark.anyio

Expand Down
7 changes: 1 addition & 6 deletions tests/triggers/test_cron.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
from __future__ import annotations

import sys
from datetime import datetime
from zoneinfo import ZoneInfo

import pytest

from apscheduler.triggers.cron import CronTrigger

if sys.version_info >= (3, 9):
from zoneinfo import ZoneInfo
else:
from backports.zoneinfo import ZoneInfo


def test_invalid_expression():
exc = pytest.raises(ValueError, CronTrigger, year="2009-fault")
Expand Down

0 comments on commit 7960ad1

Please sign in to comment.