Skip to content

Commit

Permalink
Update typing for setuptools
Browse files Browse the repository at this point in the history
The inspiration for this change was the following warning from `poetry`:

    Warning: The locked version 0.1.3 for types-pkg-resources is a yanked
    version. Reason for being yanked: Use types-setuptools instead

Following that, adding `types-setuptools` allowed the removal of some
`type: ignore` comments, which then lead to a single issue needing to be
fixed:

    tests/unit/test_setuptools_command.py:8: error: Argument 1 to "ISortCommand" has incompatible type "distutils.dist.Distribution"; expected "setuptools.dist.Distribution"  [arg-type]

Co-authored-by: Matthew Hughes <[email protected]>
  • Loading branch information
DanielNoord and matthewhughes934 committed Jan 9, 2025
1 parent 0d43980 commit 2063cda
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions isort/setuptools_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from typing import Any, Dict, Iterator, List
from warnings import warn

import setuptools # type: ignore
import setuptools

from . import api
from .settings import DEFAULT_CONFIG


class ISortCommand(setuptools.Command): # type: ignore
class ISortCommand(setuptools.Command):
"""The :class:`ISortCommand` class is used by setuptools to perform
imports checks on registered modules.
"""
Expand Down
24 changes: 12 additions & 12 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ mypy-extensions = ">=0.4.3"
pre-commit = ">=2.13.0"
pytest-benchmark = ">=3.4.1"
toml = ">=0.10.2"
types-pkg-resources = ">=0.1.2"
types-setuptools = ">=70.0.0.20240523"
types-colorama = ">=0.4.2"
types-toml = ">=0.1.3"
vulture = ">=1.0"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_setuptools_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

def test_isort_command_smoke(src_dir):
"""A basic smoke test for the setuptools_commands command"""
from distutils.dist import Distribution
from setuptools.dist import Distribution

command = setuptools_commands.ISortCommand(Distribution())
command.distribution.packages = ["isort"]
Expand Down

0 comments on commit 2063cda

Please sign in to comment.