Skip to content

Commit

Permalink
Upgrade ruff target version to Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Elkiwa committed Dec 12, 2023
1 parent 5e80a6d commit 47b9434
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 36 deletions.
12 changes: 2 additions & 10 deletions pydantic/plugin/_loader.py
@@ -1,16 +1,8 @@
from __future__ import annotations

import sys
import importlib.metadata as importlib_metadata
import warnings
from typing import TYPE_CHECKING, Iterable

from typing_extensions import Final

if sys.version_info >= (3, 8):
import importlib.metadata as importlib_metadata
else:
import importlib_metadata

from typing import TYPE_CHECKING, Final, Iterable

if TYPE_CHECKING:
from . import PydanticPluginProtocol
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -181,7 +181,7 @@ extend-ignore = ['D105', 'D107', 'D205', 'D415']
flake8-quotes = {inline-quotes = 'single', multiline-quotes = 'double'}
mccabe = { max-complexity = 14 }
isort = { known-first-party = ['pydantic', 'tests'] }
target-version = "py37"
target-version = "py38"
extend-exclude = ['pydantic/v1', 'tests/mypy/outputs']

[tool.ruff.extend-per-file-ignores]
Expand Down
34 changes: 16 additions & 18 deletions tests/test_edge_cases.py
Expand Up @@ -2724,22 +2724,20 @@ def test_eq_with_cached_property():
model instances. This is not compatible with e.g. functools.cached_property,
which caches the computed values in the instance's __dict__
"""
# functools.cached_property doesn't exist in python 3.7
if sys.version_info >= (3, 8):

class Model(BaseModel):
attr: int

@functools.cached_property
def cached(self) -> int:
return 0

obj1 = Model(attr=1)
obj2 = Model(attr=1)
# ensure the instances are indeed equal before __dict__ mutations
assert obj1 == obj2
# This access to the cached_property has the side-effect of modifying obj1.__dict__
# See functools.cached_property documentation and source code
obj1.cached
# Ensure the objects still compare equals after caching a property
assert obj1 == obj2
class Model(BaseModel):
attr: int

@functools.cached_property
def cached(self) -> int:
return 0

obj1 = Model(attr=1)
obj2 = Model(attr=1)
# ensure the instances are indeed equal before __dict__ mutations
assert obj1 == obj2
# This access to the cached_property has the side-effect of modifying obj1.__dict__
# See functools.cached_property documentation and source code
obj1.cached
# Ensure the objects still compare equals after caching a property
assert obj1 == obj2
8 changes: 1 addition & 7 deletions tests/test_typing.py
Expand Up @@ -27,13 +27,7 @@
except ImportError:
typing_extensions_TypedDict = None


try:
from mypy_extensions import TypedDict as mypy_extensions_TypedDict
except ImportError:
mypy_extensions_TypedDict = None

ALL_TYPEDDICT_KINDS = (typing_TypedDict, typing_extensions_TypedDict, mypy_extensions_TypedDict)
ALL_TYPEDDICT_KINDS = (typing_TypedDict, typing_extensions_TypedDict)


def test_is_namedtuple():
Expand Down

0 comments on commit 47b9434

Please sign in to comment.