Skip to content

Commit

Permalink
Dropped Black: Replaced black code linting with ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
eadwinCode committed Dec 14, 2023
1 parent dcec131 commit 7ab75ca
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/test_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ jobs:
run: pip install flit
- name: Install Dependencies
run: flit install --symlink
- name: Black
run: black --check ninja_schema tests
- name: Ruff Linting Check
run: ruff check ninja_schema tests
- name: mypy
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ install:clean ## Install dependencies
pre-commit install -f

lint:fmt ## Run code linters
black --check ninja_schema tests
ruff check ninja_schema tests
mypy ninja_schema

fmt format:clean ## Run code formatters
black ninja_schema tests
ruff format ninja_schema tests
ruff check --fix ninja_schema tests

test:clean ## Run tests
Expand Down
4 changes: 1 addition & 3 deletions ninja_schema/orm/model_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,7 @@ def dict(self, *a: Any, **kw: Any) -> Dict[str, Any]:

def json(self, *a, **kw) -> str:
# Backward compatibility with pydantic 1.x
return self.model_dump_json(
*a, **kw
) # type:ignore[attr-defined,no-any-return]
return self.model_dump_json(*a, **kw) # type:ignore[attr-defined,no-any-return]

@classmethod
def json_schema(cls) -> Dict[str, Any]:
Expand Down
6 changes: 3 additions & 3 deletions ninja_schema/orm/schema_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def __init__(self) -> None:
def register_model(self, model: Type[Model], schema: Type["ModelSchema"]) -> None:
from .model_schema import ModelSchema

assert is_valid_class(schema) and issubclass(
schema, (ModelSchema,)
), "Only Schema can be" 'registered, received "{}"'.format(schema.__name__)
assert is_valid_class(schema) and issubclass(schema, (ModelSchema,)), (
"Only Schema can be" 'registered, received "{}"'.format(schema.__name__)
)
assert is_valid_django_model(
model
), "Only Django Models are allowed. {}".format(model.__name__)
Expand Down
6 changes: 4 additions & 2 deletions ninja_schema/orm/utils/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def convert_choice_name(name: str) -> str:
def get_choices(
choices: t.Iterable[
t.Union[t.Tuple[t.Any, t.Any], t.Tuple[str, t.Iterable[t.Tuple[t.Any, t.Any]]]]
]
],
) -> t.Iterator[t.Tuple[str, str, str]]:
for value, help_text in choices:
if isinstance(help_text, (tuple, list)):
Expand Down Expand Up @@ -190,7 +190,9 @@ def construct_relational_field_info(
if IS_PYDANTIC_V1:
python_type = t.List[m2m_type]
else:
python_type = t.List[Annotated[inner_type, BeforeValidator(m2m_type.validate)]] # type: ignore
python_type = t.List[
Annotated[inner_type, BeforeValidator(m2m_type.validate)]
] # type: ignore

field_info = PydanticField(
default=default,
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ test = [
"pytest-cov",
"pytest-django",
"pytest-asyncio",
"mypy ==1.5.1",
"ruff ==0.0.275",
"black == 23.7.0",
"mypy == 1.7.1",
"ruff ==0.1.7",
"django-stubs",
]
dev = [
Expand Down

0 comments on commit 7ab75ca

Please sign in to comment.