Skip to content

Commit 36e6157

Browse files
committed
Improve Wikicode/Node typing
1 parent 4bcd87e commit 36e6157

File tree

14 files changed

+663
-120
lines changed

14 files changed

+663
-120
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
v0.7.2 (unreleased):
22

33
- Fix building on non-CPython implementations like PyPy. (#341)
4+
- Improve typing.
45

56
v0.7.1 (released June 30, 2025):
67

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Unreleased
99

1010
- Fix building on non-CPython implementations like PyPy.
1111
(`#341 <https://github.com/earwig/mwparserfromhell/issues/341>`_)
12+
- Improve typing.
1213

1314
v0.7.1
1415
------

docs/integration.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Integration
77
:func:`mwparserfromhell.parse() <mwparserfromhell.__init__.parse>` on
88
:meth:`~earwigbot.wiki.page.Page.get`.
99

10-
If you're using Pywikibot_, your code might look like this:
10+
If you're using Pywikibot_, your code might look like this::
1111

1212
import mwparserfromhell
1313
import pywikibot
@@ -19,7 +19,7 @@ If you're using Pywikibot_, your code might look like this:
1919
return mwparserfromhell.parse(text)
2020

2121
If you're not using a library, you can parse any page with the following
22-
Python 3 code (using the API_ and the requests_ library):
22+
Python 3 code (using the API_ and the requests_ library)::
2323

2424
import mwparserfromhell
2525
import requests

mypy.ini

Lines changed: 0 additions & 9 deletions
This file was deleted.

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,9 @@ extend-select = [
7272
"I",
7373
"UP",
7474
]
75+
76+
[tool.mypy]
77+
disallow_incomplete_defs = true
78+
warn_return_any = true
79+
warn_unused_configs = true
80+
warn_unused_ignores = true

src/mwparserfromhell/nodes/external_link.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(
4444
):
4545
super().__init__()
4646
self.url = url
47-
self.title = title
47+
self.title = title # pyright: ignore[reportIncompatibleMethodOverride]
4848
self.brackets = brackets
4949
self.suppress_space = suppress_space
5050

src/mwparserfromhell/nodes/heading.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Heading(Node):
3535

3636
def __init__(self, title: Any, level: int):
3737
super().__init__()
38-
self.title = title
38+
self.title = title # pyright: ignore[reportIncompatibleMethodOverride]
3939
self.level = level
4040

4141
def __str__(self) -> str:

src/mwparserfromhell/nodes/template.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ def get(self, name: str | Any, default: T = _UNSET) -> Parameter | T:
260260
raise ValueError(name)
261261
return default
262262

263-
def __getitem__(self, name: str | Any) -> Parameter:
263+
def __getitem__( # pyright: ignore[reportIncompatibleMethodOverride]
264+
self, name: str | Any
265+
) -> Parameter:
264266
return self.get(name)
265267

266268
def add(

src/mwparserfromhell/nodes/wikilink.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Wikilink(Node):
3737

3838
def __init__(self, title: Any, text: Any = None):
3939
super().__init__()
40-
self.title = title
40+
self.title = title # pyright: ignore[reportIncompatibleMethodOverride]
4141
self.text = text
4242

4343
def __str__(self) -> str:

src/mwparserfromhell/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)