Skip to content

Commit

Permalink
Add custom types rule to codemods module
Browse files Browse the repository at this point in the history
  • Loading branch information
JensHeinrich authored and JensHeinrich committed Aug 11, 2023
1 parent a55809e commit 2c050a7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bump_pydantic/codemods/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from bump_pydantic.codemods.add_default_none import AddDefaultNoneCommand
from bump_pydantic.codemods.con_func import ConFuncCallCommand
from bump_pydantic.codemods.custom_types import CustomTypeCodemod
from bump_pydantic.codemods.field import FieldCodemod
from bump_pydantic.codemods.replace_config import ReplaceConfigCodemod
from bump_pydantic.codemods.replace_generic_model import ReplaceGenericModelCommand
Expand All @@ -31,6 +32,8 @@ class Rule(str, Enum):
"""Replace `@validator` with `@field_validator`."""
BP008 = "BP008"
"""Replace `con*` functions by `Annotated` versions."""
BP010 = "BP010"
"""Mark pydantic 'protocol' functions in custom types with proper TODOs"""


def gather_codemods(disabled: List[Rule]) -> List[Type[ContextAwareTransformer]]:
Expand Down Expand Up @@ -61,6 +64,9 @@ def gather_codemods(disabled: List[Rule]) -> List[Type[ContextAwareTransformer]]
if Rule.BP007 not in disabled:
codemods.append(ValidatorCodemod)

if Rule.BP010 not in disabled:
codemods.append(CustomTypeCodemod)

# Those codemods need to be the last ones.
codemods.extend([RemoveImportsVisitor, AddImportsVisitor])
return codemods

0 comments on commit 2c050a7

Please sign in to comment.