Skip to content

Commit

Permalink
remove python 3.7
Browse files Browse the repository at this point in the history
* bump pre-commit
* modify GitHub actions
* improve dependency definitions
* avoid deprecation warnings
  • Loading branch information
07pepa committed Oct 8, 2024
1 parent 71438c1 commit b18761a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/github-actions-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: 3.12
- uses: pre-commit/[email protected]
run-tests:
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12.3" ]
mongodb-version: [ 4.4, 5.0, 6.0, 7.0, 8.0 ]
pydantic-version: [ "1.10.15", "2.7" ]
exclude:
- python-version: "3.7"
pydantic-version: "2.7"
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12"]
mongodb-version: [4.4, 5.0, 6.0, 7.0, 8.0 ]
pydantic-version: [ "1.10.18", "2.9.2" ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.5.0
rev: v0.6.9
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.1
rev: v1.11.2
hooks:
- id: mypy
additional_dependencies:
Expand Down
2 changes: 1 addition & 1 deletion beanie/odm/queries/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ def __await__(
document = yield from self._find_one().__await__() # type: ignore
if document is None:
return None
if type(document) == self.projection_model:
if type(document) is self.projection_model:
return cast(FindQueryResultType, document)
return cast(
FindQueryResultType, parse_obj(self.projection_model, document)
Expand Down
17 changes: 9 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "beanie"
version = "1.26.0"
description = "Asynchronous Python ODM for MongoDB"
readme = "README.md"
requires-python = ">=3.7,<4.0"
requires-python = ">=3.8,<4.0"
license = { file="LICENSE" }
authors = [
{name = "Roman Right", email = "[email protected]"}
Expand All @@ -23,7 +23,8 @@ classifiers = [
"Typing :: Typed",
]
dependencies = [
"pydantic>=1.10,<3.0",
"pydantic>=1.10.18,<3.0; python_version <= '3.12.3'",
"pydantic>=1.10,<=2.0,>2.7.4,<3.0; python_version > '3.12.3'",#after 3.12.3 pydantic <2.7.4 is incompatible https://github.com/pydantic/pydantic/pull/9615
"motor>=2.5.0,<4.0.0",
"click>=7",
"toml",
Expand All @@ -33,12 +34,11 @@ dependencies = [

[project.optional-dependencies]
test = [
"pre-commit>=2.3.0",
"pytest>=6.0.0",
"pytest-asyncio>=0.21.0",
"pytest-cov>=2.8.1",
"pre-commit>=3.5.0",
"pytest>=8.3.3",
"pytest-asyncio>=0.24.0",
"pytest-cov>=5.0.0",
"dnspython>=2.1.0",
"flake8>=3",
"pyright>=0",
"asgi-lifespan>=1.0.1",
"httpx>=0.23.0",
Expand Down Expand Up @@ -78,7 +78,7 @@ beanie = "beanie.executors.migrate:migrations"
# TOOLS

[tool.pytest.ini_options]
minversion = "6.0"
minversion = "8.0"
addopts = "--cov-report term-missing --cov=beanie --cov-branch --cov-fail-under=80"
testpaths = [
"tests",
Expand All @@ -89,6 +89,7 @@ filterwarnings = [
"ignore::UserWarning",
]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"

[tool.beanie.migrations]
path = "beanie/example_migration"
Expand Down
12 changes: 9 additions & 3 deletions tests/odm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,9 @@ class DocumentWithListOfLinks(Document):


class DocumentWithTimeStampToTestConsistency(Document):
ts: datetime.datetime = Field(default_factory=datetime.datetime.utcnow)
ts: datetime.datetime = Field(
default_factory=lambda: datetime.datetime.now(datetime.timezone.utc)
)


class DocumentWithIndexMerging1(Document):
Expand Down Expand Up @@ -1155,8 +1157,12 @@ class DocumentWithEnumKeysDict(Document):
class BsonRegexDoc(Document):
regex: Optional[Regex] = None

class Config:
arbitrary_types_allowed = True
if IS_PYDANTIC_V2:
model_config = ConfigDict(arbitrary_types_allowed=True)
else:

class Config:
arbitrary_types_allowed = True


class NativeRegexDoc(Document):
Expand Down

0 comments on commit b18761a

Please sign in to comment.