Skip to content

Commit

Permalink
Bump ruff to 0.3.4 (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex committed Mar 29, 2024
1 parent aa6dff5 commit 1296c19
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions bump_pydantic/codemods/class_def_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion bump_pydantic/codemods/replace_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
1 change: 1 addition & 0 deletions bump_pydantic/codemods/replace_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
4. `from pydantic.settings import BaseSettings as <name>` # TODO: This is not working.
5. `import pydantic` -> `pydantic.BaseSettings`
"""

from __future__ import annotations

from dataclasses import dataclass
Expand Down
4 changes: 3 additions & 1 deletion bump_pydantic/codemods/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
15 changes: 6 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand All @@ -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',
Expand All @@ -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
Expand Down

0 comments on commit 1296c19

Please sign in to comment.