diff --git a/bump_pydantic/codemods/class_def_visitor.py b/bump_pydantic/codemods/class_def_visitor.py index f911fc3..b97aa0e 100644 --- a/bump_pydantic/codemods/class_def_visitor.py +++ b/bump_pydantic/codemods/class_def_visitor.py @@ -9,6 +9,7 @@ 1.1. If it is, and if any `base_model_cls` is found, remove from `cls`, and add to `base_model_cls`. 1.2. If it's not, it continues on the `cls` """ + from __future__ import annotations from collections import defaultdict diff --git a/bump_pydantic/codemods/replace_config.py b/bump_pydantic/codemods/replace_config.py index f1c6ff7..9eef776 100644 --- a/bump_pydantic/codemods/replace_config.py +++ b/bump_pydantic/codemods/replace_config.py @@ -9,7 +9,9 @@ PREFIX_COMMENT = "# TODO[pydantic]: " REFACTOR_COMMENT = f"{PREFIX_COMMENT}We couldn't refactor this class, please create the `model_config` manually." REMOVED_KEYS_COMMENT = f"{PREFIX_COMMENT}The following keys were removed: {{keys}}." -INHERIT_CONFIG_COMMENT = f"{PREFIX_COMMENT}The `Config` class inherits from another class, please create the `model_config` manually." # noqa: E501 +INHERIT_CONFIG_COMMENT = ( + f"{PREFIX_COMMENT}The `Config` class inherits from another class, please create the `model_config` manually." +) CHECK_LINK_COMMENT = "# Check https://docs.pydantic.dev/dev-v2/migration/#changes-to-config for more information." REMOVED_KEYS = [ diff --git a/bump_pydantic/codemods/replace_imports.py b/bump_pydantic/codemods/replace_imports.py index 81e6ca7..6030224 100644 --- a/bump_pydantic/codemods/replace_imports.py +++ b/bump_pydantic/codemods/replace_imports.py @@ -7,6 +7,7 @@ 4. `from pydantic.settings import BaseSettings as ` # TODO: This is not working. 5. `import pydantic` -> `pydantic.BaseSettings` """ + from __future__ import annotations from dataclasses import dataclass diff --git a/bump_pydantic/codemods/validator.py b/bump_pydantic/codemods/validator.py index a2fe7fc..2a771b9 100644 --- a/bump_pydantic/codemods/validator.py +++ b/bump_pydantic/codemods/validator.py @@ -7,7 +7,9 @@ from libcst.codemod.visitors import AddImportsVisitor, RemoveImportsVisitor PREFIX_COMMENT = "# TODO[pydantic]: " -REFACTOR_COMMENT = f"{PREFIX_COMMENT}We couldn't refactor the `{{old_name}}`, please replace it by `{{new_name}}` manually." # noqa: E501 +REFACTOR_COMMENT = ( + f"{PREFIX_COMMENT}We couldn't refactor the `{{old_name}}`, please replace it by `{{new_name}}` manually." +) VALIDATOR_COMMENT = REFACTOR_COMMENT.format(old_name="validator", new_name="field_validator") ROOT_VALIDATOR_COMMENT = REFACTOR_COMMENT.format(old_name="root_validator", new_name="model_validator") CHECK_LINK_COMMENT = "# Check https://docs.pydantic.dev/dev-v2/migration/#changes-to-validators for more information." diff --git a/pyproject.toml b/pyproject.toml index 9e50f7b..4de1cc8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,18 +48,13 @@ dependencies = [ "pytest", "rich", "rtoml", - "ruff==0.1.9", + "ruff==0.3.4", ] [tool.hatch.envs.default.scripts] cov = ["test-cov", "cov-report"] cov-report = ["- coverage combine", "coverage report"] -format = ["black {args:.}", "ruff --fix {args:.}"] -lint = [ - "ruff {args:.}", - "black --check --diff {args:.}", - "mypy {args:bump_pydantic tests}", -] +lint = ["ruff format {args:.}", "ruff check --fix --exit-non-zero-on-fix {args:.}", "mypy {args:bump_pydantic tests}"] test = "pytest {args:tests}" test-cov = "coverage run -m pytest {args:tests}" @@ -72,6 +67,10 @@ skip-string-normalization = true target-version = ["py38"] [tool.ruff] +line-length = 120 +target-version = 'py38' + +[tool.ruff.lint] extend-select = [ 'A', 'B', @@ -88,9 +87,7 @@ extend-select = [ ] ignore = ['B008'] # That's how Typer works. isort = { known-first-party = ['bump_pydantic', 'tests'] } -line-length = 120 mccabe = { max-complexity = 14 } -target-version = 'py38' [tool.pytest.ini_options] xfail_strict = true