From 64aa24568ba0cb5eb6b7b4caafbe7e1682cddfa1 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sat, 31 Aug 2024 14:33:10 -0400 Subject: [PATCH] Pass mypy and link issues --- jaraco/mongodb/check-gridfs.py | 4 +- jaraco/mongodb/codec.py | 2 +- jaraco/mongodb/insert-doc.py | 4 +- jaraco/mongodb/install.py | 3 +- jaraco/mongodb/monitor-index-creation.py | 4 +- jaraco/mongodb/move-gridfs.py | 5 ++- jaraco/mongodb/repair-gridfs.py | 2 +- mypy.ini | 50 +++++++++++++++++++++++- pyproject.toml | 4 -- 9 files changed, 61 insertions(+), 17 deletions(-) diff --git a/jaraco/mongodb/check-gridfs.py b/jaraco/mongodb/check-gridfs.py index 301b82d..89f8106 100644 --- a/jaraco/mongodb/check-gridfs.py +++ b/jaraco/mongodb/check-gridfs.py @@ -45,8 +45,8 @@ def handle_trap(self, trap): @autocommand.autocommand(__name__) def run( - db: helper.connect_gridfs, # type: ignore - depth: (int, 'Bytes to read into each file during check') = 1024, # type: ignore # noqa: F722 + db: helper.connect_gridfs, + depth: (int, 'Bytes to read into each file during check') = 1024, # noqa: F722 ): logging.basicConfig(stream=sys.stderr) diff --git a/jaraco/mongodb/codec.py b/jaraco/mongodb/codec.py index 9398a3a..7bed275 100644 --- a/jaraco/mongodb/codec.py +++ b/jaraco/mongodb/codec.py @@ -42,4 +42,4 @@ def maybe_date(obj): smart_hook = compose(maybe_date, collections.OrderedDict) -decode = functools.partial(json.loads, object_pairs_hook=smart_hook) # type: ignore +decode = functools.partial(json.loads, object_pairs_hook=smart_hook) # type: ignore[arg-type] diff --git a/jaraco/mongodb/insert-doc.py b/jaraco/mongodb/insert-doc.py index e63c762..5ed510f 100644 --- a/jaraco/mongodb/insert-doc.py +++ b/jaraco/mongodb/insert-doc.py @@ -12,8 +12,8 @@ def get_collection(uri: str) -> pymongo.collection.Collection: @autocommand.autocommand(__name__) -def main(collection: get_collection): # type: ignore +def main(collection: get_collection): """ Insert a document from stdin into the specified collection. """ - collection.insert_one(json.load(sys.stdin)) # type: ignore + collection.insert_one(json.load(sys.stdin)) # type: ignore[attr-defined] diff --git a/jaraco/mongodb/install.py b/jaraco/mongodb/install.py index 503b857..7c1dd92 100644 --- a/jaraco/mongodb/install.py +++ b/jaraco/mongodb/install.py @@ -77,8 +77,7 @@ def _extract_application_zip(resp, target): def _extract_application_gzip(resp, target): with tarfile.open(fileobj=resp, mode='r|*') as obj: roots = RootFinder() - # python/typeshed#10514 - obj.extractall(target, filter=roots) # type: ignore + obj.extractall(target, filter=roots) return roots diff --git a/jaraco/mongodb/monitor-index-creation.py b/jaraco/mongodb/monitor-index-creation.py index 3c3923c..47a476e 100644 --- a/jaraco/mongodb/monitor-index-creation.py +++ b/jaraco/mongodb/monitor-index-creation.py @@ -14,9 +14,9 @@ def is_index_op(op): @autocommand.autocommand(__name__) -def run(db: helper.connect_db): # type: ignore +def run(db: helper.connect_db): while True: - ops = db.current_op()['inprog'] # type: ignore + ops = db.current_op()['inprog'] # type: ignore[attr-defined] index_op = next(filter(is_index_op, ops), None) if not index_op: print("No index operations in progress") diff --git a/jaraco/mongodb/move-gridfs.py b/jaraco/mongodb/move-gridfs.py index b5ec0bc..4f8325d 100644 --- a/jaraco/mongodb/move-gridfs.py +++ b/jaraco/mongodb/move-gridfs.py @@ -18,12 +18,13 @@ ['test.txt'] """ +from __future__ import annotations + import itertools import logging import signal import sys -import autocommand import bson import dateutil.parser from more_itertools.recipes import consume @@ -121,7 +122,7 @@ def run( dest_gfs: helper.connect_gridfs, include: (str, "a filter of files (regex) to include") = None, # noqa: F722 delete: (bool, "delete files after moving") = False, # noqa: F722 - limit: int = None, + limit: int = None, # type: ignore[assignment] jaraco/jaraco.mongodb#42#discussion_r1739885173 limit_date: (dateutil.parser.parse, 'only move files older than this date') = None, # noqa: F722 ): logging.basicConfig(stream=sys.stderr, level=logging.INFO) diff --git a/jaraco/mongodb/repair-gridfs.py b/jaraco/mongodb/repair-gridfs.py index 402ebe4..c19db96 100644 --- a/jaraco/mongodb/repair-gridfs.py +++ b/jaraco/mongodb/repair-gridfs.py @@ -56,7 +56,7 @@ def handle_trap(self, trap): @autocommand.autocommand(__name__) -def run(db: helper.connect_gridfs): # type: ignore +def run(db: helper.connect_gridfs): logging.basicConfig(stream=sys.stderr, level=logging.INFO) repair = FileRepair(db) diff --git a/mypy.ini b/mypy.ini index efcb8cb..cdae571 100644 --- a/mypy.ini +++ b/mypy.ini @@ -11,5 +11,53 @@ enable_error_code = ignore-without-code explicit_package_bases = True disable_error_code = - # Disable due to many false positives + # Disable overload-overlap due to many false-positives overload-overlap, + # TODO: Consider Annotated and/or replacing autocommand jaraco/jaraco.develop#20 + valid-type, + syntax, + +# jaraco/backports.tarfile#1 +[mypy-backports.*] +ignore_missing_imports = True + +# jaraco/jaraco.itertools#20 +[mypy-jaraco.itertools.*] +ignore_missing_imports = True + +# jaraco/jaraco.ui#4 +[mypy-jaraco.ui.*] +ignore_missing_imports = True + +# jaraco/jaraco.logging#6 +[mypy-jaraco.logging.*] +ignore_missing_imports = True + +# jaraco/jaraco.services#5 +[mypy-jaraco.services.*] +ignore_missing_imports = True + +# jaraco/tempora#35 +[mypy-tempora.*] +ignore_missing_imports = True + +# jaraco/portend#17 +[mypy-portend.*] +ignore_missing_imports = True + +# pmxbot/pmxbot#113 +[mypy-pmxbot.*] +ignore_missing_imports = True + +# cherrypy/cherrypy#1510 +[mypy-cherrypy.*] +ignore_missing_imports = True + +# jaraco/jaraco.develop#20 +# Lucretiel/autocommand#38 +[mypy-autocommand.*] +ignore_missing_imports = True + +# TODO: Raise issue upstream +[mypy-pytimeparse.*] +ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml index 002dd6d..44ca5f3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,7 +93,3 @@ pytest11 = {MongoDB = "jaraco.mongodb.fixtures"} [tool.setuptools_scm] - - -[tool.pytest-enabler.mypy] -# Disabled due to jaraco/skeleton#143