Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump dependencies #465

Merged
merged 6 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default_language_version:
python: "3.11"
repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v2.4.0
rev: v3.0.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
Expand All @@ -18,16 +18,16 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/pdm-project/pdm
rev: 2.9.3
rev: 2.11.1
hooks:
- id: pdm-lock-check
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.1.1"
rev: "v0.1.8"
hooks:
- id: ruff
args: ["--fix"]
- repo: https://github.com/psf/black
rev: 23.10.0
rev: 23.12.0
hooks:
- id: black
args: [--config=./pyproject.toml]
Expand All @@ -36,12 +36,12 @@ repos:
hooks:
- id: codespell
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.3"
rev: "v3.1.0"
hooks:
- id: prettier
exclude: ".all-contributorsrc"
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.6.1"
rev: "v1.7.1"
hooks:
- id: mypy
exclude: "test_decimal_constraints|examples/fields/test_example_2|examples/configuration|tools/"
Expand All @@ -52,14 +52,14 @@ repos:
hypothesis,
mongomock_motor,
msgspec,
odmantic,
odmantic<1,
pydantic>=2,
pytest,
sphinx,
sqlalchemy>=2,
]
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.332
rev: v1.1.341
hooks:
- id: pyright
exclude: "tests"
Expand All @@ -70,13 +70,13 @@ repos:
hypothesis,
mongomock_motor,
msgspec,
odmantic,
odmantic<1,
pydantic>=2,
pytest,
sphinx,
sqlalchemy>=2,
]
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: "v0.8.1"
rev: "v0.9.1"
hooks:
- id: sphinx-lint
1,766 changes: 1,085 additions & 681 deletions pdm.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion polyfactory/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, method: Callable | classmethod) -> None:
def __get__(self, obj: Any, objtype: type) -> PostGenerated:
with contextlib.suppress(KeyError):
return self.cache[objtype]
fn = self.method.__func__
fn = self.method.__func__ # pyright: ignore[reportFunctionMemberAccess]
fn_args = inspect.getfullargspec(fn).args[1:]

def new_fn(name: str, values: dict[str, Any]) -> Any: # noqa: ARG001 - investigate @guacs
Expand Down
8 changes: 6 additions & 2 deletions polyfactory/factories/pydantic_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ def from_field_info(
if callable(field_info.default_factory):
default_value = field_info.default_factory()
else:
default_value = field_info.default if field_info.default is not Undefined else Null
default_value = (
field_info.default
if field_info.default is not Undefined # pyright: ignore[reportUnboundVariable]
else Null
)

annotation = unwrap_new_type(field_info.annotation)
children: list[FieldMeta,] | None = None
Expand Down Expand Up @@ -359,7 +363,7 @@ def get_constrained_field_value(cls, annotation: Any, field_meta: FieldMeta) ->
constraints = cast(PydanticConstraints, field_meta.constraints)
if constraints.pop("json", None):
value = cls.get_field_value(field_meta)
return to_json(value)
return to_json(value) # pyright: ignore[reportUnboundVariable]

return super().get_constrained_field_value(annotation, field_meta)

Expand Down
2 changes: 1 addition & 1 deletion polyfactory/value_generators/regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __call__(self, string_or_regex: str | Pattern) -> str:
"""
pattern = string_or_regex.pattern if isinstance(string_or_regex, Pattern) else string_or_regex
parsed = parse(pattern)
result = self._build_string(parsed)
result = self._build_string(parsed) # pyright: ignore[reportGeneralTypeIssues]
self._cache.clear()
return result

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dependencies = [
sqlalchemy = ["sqlalchemy>=1.4.29",]
pydantic = ["pydantic[email]",]
msgspec = ["msgspec",]
odmantic = ["odmantic", "pydantic[email]",]
odmantic = ["odmantic<1.0.0", "pydantic[email]",]
beanie = ["beanie", "pydantic[email]",]
attrs = ["attrs>=22.2.0",]
full = ["pydantic", "odmantic", "msgspec", "beanie", "attrs", "sqlalchemy"]
Expand Down
6 changes: 3 additions & 3 deletions tests/test_constrained_attribute_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ class ConstrainedModel(BaseModel):
constr_field: constr(to_lower=True) # type: ignore[valid-type]
str_field1: str = Field(min_length=11)
str_field2: str = Field(max_length=11)
str_field3: str = Field(min_length=8, max_length=11, regex=pattern)
str_field3: str = Field(min_length=8, max_length=11, regex=pattern) # type: ignore[call-arg]
int_field: int = Field(gt=1, multiple_of=5)
float_field: float = Field(gt=100, lt=1000)
decimal_field: Decimal = Field(ge=100, le=1000)
list_field: List[str] = Field(min_items=1, max_items=10)
constant_field: int = Field(const=True, default=100)
list_field: List[str] = Field(min_items=1, max_items=10) # type: ignore[call-arg]
constant_field: int = Field(const=True, default=100) # type: ignore[call-arg]
optional_field: Optional[constr(min_length=1)] # type: ignore[valid-type]

class MyFactory(ModelFactory):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_options_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_factory_handling_of_optionals() -> None:
class ModelWithOptionalValues(BaseModel):
name: Optional[str]
id: str
complex: List[Optional[str]] = Field(min_items=1)
complex: List[Optional[str]] = Field(min_items=1) # type: ignore[call-arg]

class FactoryWithNoneOptionals(ModelFactory):
__model__ = ModelWithOptionalValues
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pydantic_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@pytest.mark.skipif(VERSION.startswith("2"), reason="pydantic v1 only functionality")
def test_const() -> None:
class A(BaseModel):
v: int = Field(1, const=True)
v: int = Field(1, const=True) # type: ignore[call-arg]

class AFactory(ModelFactory[A]):
__model__ = A
Expand Down
2 changes: 1 addition & 1 deletion tests/test_random_seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MyModel(BaseModel):
special_id: str = (
Field(pattern=r"ID-[1-9]{3}\.[1-9]{3}")
if VERSION.startswith("2")
else Field(regex=r"ID-[1-9]{3}\.[1-9]{3}")
else Field(regex=r"ID-[1-9]{3}\.[1-9]{3}") # type: ignore[call-arg]
)

class MyModelFactory(ModelFactory):
Expand Down
Loading