Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow blanket and unused suppressions (PGH, RUF10) #4526

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ extend-select = [

# local
"ANN2", # missing-return-type-*
"FA", # flake8-future-annotations
"F404", # late-future-import
"FA", # flake8-future-annotations
"I", # isort
"PGH", # pygrep-hooks (blanket-* rules)
"PYI", # flake8-pyi
"RUF10", # unused-noqa & redirected-noqa
"TRY", # tryceratops
"UP", # pyupgrade
"TRY",
"YTT", # flake8-2020
]
ignore = [
Expand Down
2 changes: 1 addition & 1 deletion setuptools/_distutils/compat/py38.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def removeprefix(self, prefix):

def aix_platform(osname, version, release):
try:
import _aix_support # type: ignore
import _aix_support

return _aix_support.aix_platform()
except ImportError:
Expand Down
4 changes: 3 additions & 1 deletion setuptools/config/expand.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,9 @@ def canonic_data_files(
]


def entry_points(text: str, text_source="entry-points") -> dict[str, dict]:
def entry_points(
text: str, text_source: str = "entry-points"
) -> dict[str, dict[str, str]]:
"""Given the contents of entry-points file,
process it into a 2-level dictionary (``dict[str, dict[str, str]]``).
The first level keys are entry-point groups, the second level keys are
Expand Down
5 changes: 3 additions & 2 deletions setuptools/config/pyprojecttoml.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def _obtain_readme(self, dist: Distribution) -> dict[str, str] | None:

def _obtain_entry_points(
self, dist: Distribution, package_dir: Mapping[str, str]
) -> dict[str, dict] | None:
) -> dict[str, dict[str, Any]] | None:
fields = ("entry-points", "scripts", "gui-scripts")
if not any(field in self.dynamic for field in fields):
return None
Expand All @@ -340,7 +340,8 @@ def _obtain_entry_points(
return None

groups = _expand.entry_points(text)
expanded = {"entry-points": groups}
# Any is str | dict[str, str], but causes variance issues
expanded: dict[str, dict[str, Any]] = {"entry-points": groups}

def _set_scripts(field: str, group: str):
if group in groups:
Expand Down
2 changes: 1 addition & 1 deletion setuptools/tests/config/test_apply_pyprojecttoml.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from ini2toml.api import LiteTranslator
from packaging.metadata import Metadata

import setuptools # noqa ensure monkey patch to metadata
import setuptools # noqa: F401 # ensure monkey patch to metadata
from setuptools.command.egg_info import write_requirements
from setuptools.config import expand, pyprojecttoml, setupcfg
from setuptools.config._apply_pyprojecttoml import _MissingDynamic, _some_attrgetter
Expand Down
Loading