Skip to content

Commit

Permalink
Merge branch 'main' into add-more-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludex committed Mar 29, 2024
2 parents f236402 + 1296c19 commit c5f4688
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 20 deletions.
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "monthly"
groups:
python-packages:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: monthly
groups:
github-actions:
patterns:
- "*"
16 changes: 8 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: set up python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install hatch
run: pip install hatch

- uses: pre-commit/[email protected].0
- uses: pre-commit/[email protected].1
with:
extra_args: --all-files

Expand All @@ -42,10 +42,10 @@ jobs:


steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: set up python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python-version }}"

Expand Down Expand Up @@ -78,18 +78,18 @@ jobs:
id-token: write

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: set up python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: install
run: pip install -U build

- name: check GITHUB_REF matches package version
uses: samuelcolvin/check-python-version@v3.1
uses: samuelcolvin/check-python-version@v4.1
with:
version_file_path: bump_pydantic/__init__.py

Expand Down
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
17 changes: 7 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,20 @@ path = "bump_pydantic/__init__.py"

[tool.hatch.envs.default]
dependencies = [
"black>=23.12.1",
"black==23.12.1",
"coverage[toml]>=6.5",
"mypy==1.8.0",
"pydantic",
"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 c5f4688

Please sign in to comment.