From d411290dff3b9229ac3f1161e09a46e21f75b05a Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 16 Jun 2025 16:49:46 +0200 Subject: [PATCH] Upgrade Mypy --- jedi/debug.py | 2 +- jedi/inference/__init__.py | 4 ++-- jedi/inference/docstrings.py | 2 +- jedi/inference/value/module.py | 6 +++--- jedi/inference/value/namespace.py | 2 +- setup.py | 7 ++++--- sith.py | 2 +- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/jedi/debug.py b/jedi/debug.py index 99a90601..167be41b 100644 --- a/jedi/debug.py +++ b/jedi/debug.py @@ -21,7 +21,7 @@ try: raise ImportError else: # Use colorama for nicer console output. - from colorama import Fore, init # type: ignore[import] + from colorama import Fore, init # type: ignore[import, unused-ignore] from colorama import initialise def _lazy_colorama_init(): # noqa: F811 diff --git a/jedi/inference/__init__.py b/jedi/inference/__init__.py index bd31cbd3..8e1696e2 100644 --- a/jedi/inference/__init__.py +++ b/jedi/inference/__init__.py @@ -122,14 +122,14 @@ class InferenceState: return value_set # mypy doesn't suppport decorated propeties (https://github.com/python/mypy/issues/1362) - @property # type: ignore[misc] + @property @inference_state_function_cache() def builtins_module(self): module_name = 'builtins' builtins_module, = self.import_module((module_name,), sys_path=[]) return builtins_module - @property # type: ignore[misc] + @property @inference_state_function_cache() def typing_module(self): typing_module, = self.import_module(('typing',)) diff --git a/jedi/inference/docstrings.py b/jedi/inference/docstrings.py index 8b8f6f1c..f1d0f31f 100644 --- a/jedi/inference/docstrings.py +++ b/jedi/inference/docstrings.py @@ -48,7 +48,7 @@ def _get_numpy_doc_string_cls(): global _numpy_doc_string_cache if isinstance(_numpy_doc_string_cache, (ImportError, SyntaxError)): raise _numpy_doc_string_cache - from numpydoc.docscrape import NumpyDocString # type: ignore[import] + from numpydoc.docscrape import NumpyDocString # type: ignore[import, unused-ignore] _numpy_doc_string_cache = NumpyDocString return _numpy_doc_string_cache diff --git a/jedi/inference/value/module.py b/jedi/inference/value/module.py index 6461cb4b..bfcd980e 100644 --- a/jedi/inference/value/module.py +++ b/jedi/inference/value/module.py @@ -80,7 +80,7 @@ class ModuleMixin(SubModuleDictMixin): def is_stub(self): return False - @property # type: ignore[misc] + @property @inference_state_method_cache() def name(self): return self._module_name_class(self, self.string_names[-1]) @@ -138,7 +138,7 @@ class ModuleValue(ModuleMixin, TreeValue): api_type = 'module' def __init__(self, inference_state, module_node, code_lines, file_io=None, - string_names=None, is_package=False): + string_names=None, is_package=False) -> None: super().__init__( inference_state, parent_context=None, @@ -149,7 +149,7 @@ class ModuleValue(ModuleMixin, TreeValue): self._path: Optional[Path] = None else: self._path = file_io.path - self.string_names = string_names # Optional[Tuple[str, ...]] + self.string_names: Optional[tuple[str, ...]] = string_names self.code_lines = code_lines self._is_package = is_package diff --git a/jedi/inference/value/namespace.py b/jedi/inference/value/namespace.py index 11737cc9..0ec5d341 100644 --- a/jedi/inference/value/namespace.py +++ b/jedi/inference/value/namespace.py @@ -38,7 +38,7 @@ class ImplicitNamespaceValue(Value, SubModuleDictMixin): def get_qualified_names(self): return () - @property # type: ignore[misc] + @property @inference_state_method_cache() def name(self): string_name = self.py__package__()[-1] diff --git a/setup.py b/setup.py index cfa229f3..c8bc6bba 100755 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from typing import cast from setuptools import setup, find_packages from setuptools.depends import get_module_constant @@ -9,7 +10,7 @@ __AUTHOR__ = 'David Halter' __AUTHOR_EMAIL__ = 'davidhalter88@gmail.com' # Get the version from within jedi. It's defined in exactly one place now. -version = get_module_constant("jedi", "__version__") +version = cast(str, get_module_constant("jedi", "__version__")) readme = open('README.rst').read() + '\n\n' + open('CHANGELOG.rst').read() @@ -51,9 +52,9 @@ setup(name='jedi', # latest version on 2025-06-16 'flake8==7.2.0', # latest version supporting Python 3.6 - 'mypy==0.971', + 'mypy==1.16', # Arbitrary pins, latest at the time of pinning - 'types-setuptools==67.2.0.1', + 'types-setuptools==80.9.0.20250529', ], 'docs': [ # Just pin all of these. diff --git a/sith.py b/sith.py index 1a69d2ad..c4bd4b2d 100755 --- a/sith.py +++ b/sith.py @@ -44,7 +44,7 @@ Options: --pudb Launch pudb when error is raised. """ -from docopt import docopt # type: ignore[import] +from docopt import docopt # type: ignore[import, unused-ignore] import json import os