From db4145494868edb7fdc4e9c7b8e60393e56194df Mon Sep 17 00:00:00 2001 From: Yashar Robert Date: Mon, 26 Aug 2024 18:15:41 +0200 Subject: [PATCH] Fix pre-commit problems --- .github/workflows/pre-commit.yml | 2 +- src/schematools/contrib/django/faker/__init__.py | 3 ++- .../django/management/commands/sqlmigrate_schema.py | 8 ++++---- src/schematools/loaders.py | 2 +- src/schematools/types.py | 3 +-- src/schematools/validation.py | 4 ++-- tests/django/test_model_mockers.py | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 8f53b5c9..1c9d4c36 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -17,4 +17,4 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.11' # matches what .pre-commit-config.yaml has - - uses: pre-commit/action@v3.0.1 \ No newline at end of file + - uses: pre-commit/action@v3.0.1 diff --git a/src/schematools/contrib/django/faker/__init__.py b/src/schematools/contrib/django/faker/__init__.py index aac72a4a..c8b2226e 100644 --- a/src/schematools/contrib/django/faker/__init__.py +++ b/src/schematools/contrib/django/faker/__init__.py @@ -1,8 +1,9 @@ from __future__ import annotations # noqa: D104 +from collections.abc import Callable from dataclasses import dataclass from dataclasses import field as dataclass_field -from typing import Any, Callable, ClassVar +from typing import Any, ClassVar from urllib.parse import urlparse from django.conf import settings diff --git a/src/schematools/contrib/django/management/commands/sqlmigrate_schema.py b/src/schematools/contrib/django/management/commands/sqlmigrate_schema.py index 132fb393..ee65a773 100644 --- a/src/schematools/contrib/django/management/commands/sqlmigrate_schema.py +++ b/src/schematools/contrib/django/management/commands/sqlmigrate_schema.py @@ -109,8 +109,8 @@ def handle(self, *args, **options) -> None: with tempfile.TemporaryDirectory() as tmpdir: schemas_root = Path(options["schema_url"]).parent - subprocess.run( - ["git", "clone", schemas_root, tmpdir], # noqa: S603 + subprocess.run( # noqa: S603 + ["git", "clone", schemas_root, tmpdir], ) table1 = self._load_table_from_checkout( dataset.id, options["table"], tmpdir, options["version1"] @@ -153,8 +153,8 @@ def _load_table_from_checkout( self, dataset_id: str, table_id: str, tmpdir: str, version_ref: str ) -> DatasetTableSchema: """Load a DatasetTableSchema for the specified git reference.""" - subprocess.run( - ["git", "checkout", version_ref], cwd=tmpdir, stdout=subprocess.DEVNULL # noqa: S603 + subprocess.run( # noqa: S603 + ["git", "checkout", version_ref], cwd=tmpdir, stdout=subprocess.DEVNULL ) tmp_schema_path = Path(tmpdir) / "datasets" # We create a specific schema loader, because it has to read in the data diff --git a/src/schematools/loaders.py b/src/schematools/loaders.py index de6e7add..d3570058 100644 --- a/src/schematools/loaders.py +++ b/src/schematools/loaders.py @@ -3,9 +3,9 @@ import contextlib import json import os +from collections.abc import Callable from functools import cached_property from pathlib import Path -from typing import Callable from urllib.parse import urlparse import requests diff --git a/src/schematools/types.py b/src/schematools/types.py index c1a3a3d8..b8a0fe11 100644 --- a/src/schematools/types.py +++ b/src/schematools/types.py @@ -10,13 +10,12 @@ import sys import typing from collections import UserDict -from collections.abc import Iterator, Mapping +from collections.abc import Callable, Iterator, Mapping from enum import Enum from functools import cached_property, total_ordering from re import Pattern from typing import ( Any, - Callable, ClassVar, NamedTuple, NoReturn, diff --git a/src/schematools/validation.py b/src/schematools/validation.py index c2d267c3..6e17818b 100644 --- a/src/schematools/validation.py +++ b/src/schematools/validation.py @@ -23,11 +23,11 @@ import operator import re -from collections.abc import Iterator +from collections.abc import Callable, Iterator from dataclasses import dataclass from functools import partial, wraps from pathlib import Path -from typing import Callable, cast +from typing import cast from urllib.parse import urlparse from schematools import MAX_TABLE_NAME_LENGTH diff --git a/tests/django/test_model_mockers.py b/tests/django/test_model_mockers.py index 5da82897..2441131b 100644 --- a/tests/django/test_model_mockers.py +++ b/tests/django/test_model_mockers.py @@ -83,7 +83,7 @@ def test_model_mocker_factory_sets_model_mocker_dataset_and_table_schema_through == "" ) - assert type(AfvalwegingenContainersModel.get_dataset()) == Dataset + assert isinstance(AfvalwegingenContainersModel.get_dataset(), Dataset) assert AfvalwegingenContainersModel.get_dataset() == afval_dataset assert str(AfvalwegingenContainersModel.get_dataset()) == "afvalwegingen" @@ -123,14 +123,14 @@ def test_schema_model_mockers_factory(afval_dataset): } assert "containers" in model_mockers ContainersMocker = model_mockers["containers"] - assert type(ContainersMocker) == FactoryMetaClass + assert isinstance(ContainersMocker, FactoryMetaClass) assert str(ContainersMocker) == ( ">" ) assert "clusters" in model_mockers ClustersMocker = model_mockers["clusters"] - assert type(ClustersMocker) == FactoryMetaClass + assert isinstance(ClustersMocker, FactoryMetaClass) assert str(ClustersMocker) == ( ">" )