Skip to content

Commit

Permalink
fix: Mostly undo mypy 1.10 changes
Browse files Browse the repository at this point in the history
Mypy 1.10 isn't working great even in stub tests. Partially revert f565104
  • Loading branch information
abelcheung committed Oct 26, 2024
1 parent 71f70e6 commit 992638c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lxml-stubs/etree/_factory_func.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Element: _ElementFactory
# type annotation attribute is modified.
# OE users need to use E-factory for more flexibility.
@overload
def SubElement( # type: ignore[overload-overlap]
def SubElement(
_parent: ObjectifiedElement,
_tag: _TagName,
/,
Expand Down
4 changes: 2 additions & 2 deletions lxml-stubs/etree/_xslt.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class XSLTExtension(metaclass=abc.ABCMeta):
remove_blank_text: bool = False,
) -> None: ...
@overload
def apply_templates( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
def apply_templates( # pyright: ignore[reportOverlappingOverload]
self,
context: Any,
node: Any,
Expand Down Expand Up @@ -264,7 +264,7 @@ class XSLTExtension(metaclass=abc.ABCMeta):
remove_blank_text: bool = False,
) -> None: ...
@overload
def process_children( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
def process_children( # pyright: ignore[reportOverlappingOverload]
self,
context: Any,
output_parent: None = None,
Expand Down
2 changes: 1 addition & 1 deletion lxml-stubs/html/_parse.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def document_fromstring(
base_url: str | None = None,
) -> HtmlElement: ...
@overload
def fragments_fromstring( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
def fragments_fromstring( # pyright: ignore[reportOverlappingOverload]
html: _AnyStr,
no_leading_text: Literal[True],
base_url: str | None = None,
Expand Down
4 changes: 2 additions & 2 deletions lxml-stubs/html/html5parser.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ def document_fromstring(
# 2 for html (bytes/str)
# 2 for no_leading_text (true/false)
@overload # html=bytes, no_leading_text=true
def fragments_fromstring( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
def fragments_fromstring( # pyright: ignore[reportOverlappingOverload]
html: bytes,
no_leading_text: Literal[True],
guess_charset: bool | None = None,
parser: HTMLParser | None = None,
) -> list[_Element]: ...
@overload # html=str, no_leading_text=true
def fragments_fromstring( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
def fragments_fromstring( # pyright: ignore[reportOverlappingOverload]
html: str,
no_leading_text: Literal[True],
guess_charset: None = None,
Expand Down
10 changes: 2 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,10 @@ deps =
commands =
pytest --mypy-ini-file=test-stub/mypy-pytest.ini {posargs:test-stub}

# Although mypy 1.10 itself produce no problem in stub,
# it is basically unusable for real life code that uses lxml,
# not until following improvement is done in 1.11.
# https://mypy.readthedocs.io/en/stable/changelog.html#type-inference-improvements
# So runtime test requires 1.11 instead

[testenv:py{310,311,312}-rt-lxml{49,50,51,52,53},py313-rt-lxml53]
deps =
{[testenv:pyright]deps}
mypy == 1.11.2
{[testenv:mypy]deps}
typeguard == 4.3.0
pytest == 8.3.3
html5lib == 1.1
Expand All @@ -63,7 +57,7 @@ commands =
[testenv:mypy]
deps =
{[common_dep]deps}
mypy == 1.10.1
mypy == 1.11.2
package = skip
commands = mypy {posargs:} lxml-stubs

Expand Down

0 comments on commit 992638c

Please sign in to comment.