Skip to content

Commit

Permalink
Fix a typing issue with typed scrapy, bump mypy. (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
wRAR authored Nov 19, 2024
1 parent a75802e commit 3088cc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 8 additions & 4 deletions itemadapter/_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
try:
import scrapy # pylint: disable=W0611 (unused-import)
except ImportError:
scrapy = None # type: ignore [assignment]
scrapy = None # type: ignore[assignment]
_scrapy_item_classes = ()
else:
try:
# handle deprecated base classes
_base_item_cls = getattr(scrapy.item, "_BaseItem", scrapy.item.BaseItem)
_base_item_cls = getattr(
scrapy.item,
"_BaseItem",
scrapy.item.BaseItem, # type: ignore[attr-defined]
)
except AttributeError:
_scrapy_item_classes = (scrapy.item.Item,)
else:
Expand All @@ -20,9 +24,9 @@
try:
import attr # pylint: disable=W0611 (unused-import)
except ImportError:
attr = None # type: ignore [assignment]
attr = None # type: ignore[assignment]

try:
import pydantic # pylint: disable=W0611 (unused-import)
except ImportError:
pydantic = None # type: ignore [assignment]
pydantic = None # type: ignore[assignment]
5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ commands =
[testenv:typing]
basepython = python3
deps =
mypy==1.11.2
mypy==1.13.0
attrs
pydantic
scrapy
commands =
mypy --install-types --non-interactive \
--ignore-missing-imports {posargs:itemadapter}
mypy {posargs:itemadapter}

[testenv:pylint]
deps =
Expand Down

0 comments on commit 3088cc4

Please sign in to comment.