Commit 594d4208 by Bjorn Neergaard

chore: clean up blanket noqa and type comments

parent 3e1e9953
......@@ -21,8 +21,10 @@ repos:
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-check-blanket-type-ignore
- 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
rev: v1.3.0
......
......@@ -213,7 +213,7 @@ def _get_win_folder_with_ctypes(csidl_name):
if WINDOWS:
try:
from ctypes import windll # noqa
from ctypes import windll # noqa: F401
_get_win_folder = _get_win_folder_with_ctypes
except ImportError:
......
......@@ -16,12 +16,12 @@ class PluginManager:
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._disable_plugins = disable_plugins
self._plugins: List[Plugin] = []
def load_plugins(self): # type: () -> None
def load_plugins(self) -> None:
if self._disable_plugins:
return
......@@ -33,7 +33,7 @@ class PluginManager:
def get_plugin_entry_points(self) -> List[entrypoints.EntryPoint]:
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)):
raise ValueError(
"The Poetry plugin must be an instance of Plugin or ApplicationPlugin"
......@@ -45,9 +45,7 @@ class PluginManager:
for plugin in self._plugins:
plugin.activate(*args, **kwargs)
def _load_plugin_entrypoint(
self, entrypoint
): # type: (entrypoints.EntryPoint) -> None
def _load_plugin_entrypoint(self, entrypoint: entrypoints.EntryPoint) -> None:
logger.debug(f"Loading the {entrypoint.name} plugin")
plugin = entrypoint.load()
......
......@@ -432,5 +432,5 @@ class LegacyRepository(PyPiRepository):
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)
......@@ -5,7 +5,7 @@ try:
from importlib import metadata
except ImportError:
# compatibility for python <3.8
import importlib_metadata as metadata # noqa
import importlib_metadata as metadata # noqa: F401
WINDOWS = sys.platform == "win32"
......
......@@ -78,7 +78,6 @@ def interpreter_version():
def _version_nodot(version):
# type: (PythonVersion) -> str
if any(v >= 10 for v in version):
sep = "_"
else:
......@@ -161,7 +160,7 @@ import json
import site
import sysconfig
from distutils.command.install import SCHEME_KEYS # noqa
from distutils.command.install import SCHEME_KEYS
from distutils.core import Distribution
d = Distribution()
......@@ -275,9 +274,7 @@ class SitePackages:
str, self._candidates if not writable_only else self.writable_candidates
)
)
for distribution in metadata.PathDistribution.discover(
name=name, path=path
): # type: metadata.PathDistribution
for distribution in metadata.PathDistribution.discover(name=name, path=path):
yield distribution
def find_distribution(
......
......@@ -23,7 +23,6 @@ def get_extra_package_names(
in the `extras` section of `poetry.lock`.
: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
if not extra_names:
......
try:
import zipp
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