Commit 594d4208 by Bjorn Neergaard

chore: clean up blanket noqa and type comments

parent 3e1e9953
...@@ -21,8 +21,10 @@ repos: ...@@ -21,8 +21,10 @@ repos:
- repo: https://github.com/pre-commit/pygrep-hooks - repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0 rev: v1.9.0
hooks: hooks:
- id: python-check-blanket-type-ignore
- id: python-check-mock-methods - id: python-check-mock-methods
- id: python-use-type-annotations
- id: python-check-blanket-type-ignore
- id: python-check-blanket-noqa
- repo: https://github.com/asottile/yesqa - repo: https://github.com/asottile/yesqa
rev: v1.3.0 rev: v1.3.0
......
...@@ -213,7 +213,7 @@ def _get_win_folder_with_ctypes(csidl_name): ...@@ -213,7 +213,7 @@ def _get_win_folder_with_ctypes(csidl_name):
if WINDOWS: if WINDOWS:
try: try:
from ctypes import windll # noqa from ctypes import windll # noqa: F401
_get_win_folder = _get_win_folder_with_ctypes _get_win_folder = _get_win_folder_with_ctypes
except ImportError: except ImportError:
......
...@@ -16,12 +16,12 @@ class PluginManager: ...@@ -16,12 +16,12 @@ class PluginManager:
This class registers and activates plugins. This class registers and activates plugins.
""" """
def __init__(self, type, disable_plugins=False): # type: (str, bool) -> None def __init__(self, type: str, disable_plugins: bool = False) -> None:
self._type = type self._type = type
self._disable_plugins = disable_plugins self._disable_plugins = disable_plugins
self._plugins: List[Plugin] = [] self._plugins: List[Plugin] = []
def load_plugins(self): # type: () -> None def load_plugins(self) -> None:
if self._disable_plugins: if self._disable_plugins:
return return
...@@ -33,7 +33,7 @@ class PluginManager: ...@@ -33,7 +33,7 @@ class PluginManager:
def get_plugin_entry_points(self) -> List[entrypoints.EntryPoint]: def get_plugin_entry_points(self) -> List[entrypoints.EntryPoint]:
return entrypoints.get_group_all(f"poetry.{self._type}") return entrypoints.get_group_all(f"poetry.{self._type}")
def add_plugin(self, plugin): # type: (Plugin) -> None def add_plugin(self, plugin: Plugin) -> None:
if not isinstance(plugin, (Plugin, ApplicationPlugin)): if not isinstance(plugin, (Plugin, ApplicationPlugin)):
raise ValueError( raise ValueError(
"The Poetry plugin must be an instance of Plugin or ApplicationPlugin" "The Poetry plugin must be an instance of Plugin or ApplicationPlugin"
...@@ -45,9 +45,7 @@ class PluginManager: ...@@ -45,9 +45,7 @@ class PluginManager:
for plugin in self._plugins: for plugin in self._plugins:
plugin.activate(*args, **kwargs) plugin.activate(*args, **kwargs)
def _load_plugin_entrypoint( def _load_plugin_entrypoint(self, entrypoint: entrypoints.EntryPoint) -> None:
self, entrypoint
): # type: (entrypoints.EntryPoint) -> None
logger.debug(f"Loading the {entrypoint.name} plugin") logger.debug(f"Loading the {entrypoint.name} plugin")
plugin = entrypoint.load() plugin = entrypoint.load()
......
...@@ -432,5 +432,5 @@ class LegacyRepository(PyPiRepository): ...@@ -432,5 +432,5 @@ class LegacyRepository(PyPiRepository):
return Page(response.url, response.content, response.headers) return Page(response.url, response.content, response.headers)
def _download(self, url, dest): # type: (str, str) -> None def _download(self, url: str, dest: str) -> None:
return download_file(url, dest, session=self.session) return download_file(url, dest, session=self.session)
...@@ -5,7 +5,7 @@ try: ...@@ -5,7 +5,7 @@ try:
from importlib import metadata from importlib import metadata
except ImportError: except ImportError:
# compatibility for python <3.8 # compatibility for python <3.8
import importlib_metadata as metadata # noqa import importlib_metadata as metadata # noqa: F401
WINDOWS = sys.platform == "win32" WINDOWS = sys.platform == "win32"
......
...@@ -78,7 +78,6 @@ def interpreter_version(): ...@@ -78,7 +78,6 @@ def interpreter_version():
def _version_nodot(version): def _version_nodot(version):
# type: (PythonVersion) -> str
if any(v >= 10 for v in version): if any(v >= 10 for v in version):
sep = "_" sep = "_"
else: else:
...@@ -161,7 +160,7 @@ import json ...@@ -161,7 +160,7 @@ import json
import site import site
import sysconfig import sysconfig
from distutils.command.install import SCHEME_KEYS # noqa from distutils.command.install import SCHEME_KEYS
from distutils.core import Distribution from distutils.core import Distribution
d = Distribution() d = Distribution()
...@@ -275,9 +274,7 @@ class SitePackages: ...@@ -275,9 +274,7 @@ class SitePackages:
str, self._candidates if not writable_only else self.writable_candidates str, self._candidates if not writable_only else self.writable_candidates
) )
) )
for distribution in metadata.PathDistribution.discover( for distribution in metadata.PathDistribution.discover(name=name, path=path):
name=name, path=path
): # type: metadata.PathDistribution
yield distribution yield distribution
def find_distribution( def find_distribution(
......
...@@ -23,7 +23,6 @@ def get_extra_package_names( ...@@ -23,7 +23,6 @@ def get_extra_package_names(
in the `extras` section of `poetry.lock`. in the `extras` section of `poetry.lock`.
:param extra_names: A list of strings specifying names of extra groups to resolve. :param extra_names: A list of strings specifying names of extra groups to resolve.
""" """
from poetry.core.packages.package import Package # noqa
from poetry.utils.helpers import canonicalize_name from poetry.utils.helpers import canonicalize_name
if not extra_names: if not extra_names:
......
try: try:
import zipp import zipp
except ImportError: except ImportError:
import zipfile as zipp # noqa import zipfile as zipp # noqa: F401
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment