From: CaselIT Date: Mon, 30 Aug 2021 19:39:40 +0000 (+0200) Subject: fix mypy errors X-Git-Tag: rel_1_7_1~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ecf6217ab5096bda75fd8ae4e819f412c020c096;p=thirdparty%2Fsqlalchemy%2Falembic.git fix mypy errors Change-Id: If49e0ff00f0b00ed914ddb8979ae49c3a8a10a0e --- diff --git a/alembic/operations/batch.py b/alembic/operations/batch.py index f5ff0bba..ef182fdc 100644 --- a/alembic/operations/batch.py +++ b/alembic/operations/batch.py @@ -466,9 +466,11 @@ class ApplyBatchImpl: if ( "existing_type" in kw and isinstance(kw["existing_type"], SchemaEventTarget) - and kw["existing_type"].name + and kw["existing_type"].name # type:ignore[attr-defined] ): - self.named_constraints.pop(kw["existing_type"].name, None) + self.named_constraints.pop( + kw["existing_type"].name, None # type:ignore[attr-defined] + ) if type_ is not None: type_ = sqltypes.to_instance(type_) @@ -590,9 +592,11 @@ class ApplyBatchImpl: if ( "existing_type" in kw and isinstance(kw["existing_type"], SchemaEventTarget) - and kw["existing_type"].name + and kw["existing_type"].name # type:ignore[attr-defined] ): - self.named_constraints.pop(kw["existing_type"].name, None) + self.named_constraints.pop( + kw["existing_type"].name, None # type:ignore[attr-defined] + ) def create_column_comment(self, column): """the batch table creation function will issue create_column_comment diff --git a/alembic/util/compat.py b/alembic/util/compat.py index d0e6672c..1e435a82 100644 --- a/alembic/util/compat.py +++ b/alembic/util/compat.py @@ -27,12 +27,12 @@ class EncodedIO(io.TextIOWrapper): if py39: from importlib import resources as importlib_resources else: - import importlib_resources # noqa + import importlib_resources # type:ignore[no-redef] # noqa if py38: from importlib import metadata as importlib_metadata else: - import importlib_metadata # noqa + import importlib_metadata # type:ignore[no-redef] # noqa def importlib_metadata_get(group): diff --git a/alembic/util/pyfiles.py b/alembic/util/pyfiles.py index 3da32c31..b6662b71 100644 --- a/alembic/util/pyfiles.py +++ b/alembic/util/pyfiles.py @@ -58,7 +58,7 @@ def coerce_resource_to_filename(fname: str) -> str: ref = compat.importlib_resources.files(tokens[0]) for tok in tokens[1:]: ref = ref / tok - fname = file_manager.enter_context( + fname = file_manager.enter_context( # type: ignore[assignment] compat.importlib_resources.as_file(ref) ) return fname diff --git a/setup.cfg b/setup.cfg index 992a7ac4..d034e617 100644 --- a/setup.cfg +++ b/setup.cfg @@ -127,3 +127,9 @@ ignore_missing_imports = True [mypy-sqlalchemy.testing.*] ignore_missing_imports = True + +[mypy-importlib_resources.*] +ignore_missing_imports = True + +[mypy-importlib_metadata.*] +ignore_missing_imports = True