Skip to content

Commit 9871c24

Browse files
authored
refactor!(types): Strict mypy compliance (#390)
2 parents c72f17c + 55e6190 commit 9871c24

40 files changed

+846
-461
lines changed

.tmuxp.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ windows:
1212
panes:
1313
- focus: true
1414
- pane
15+
- make watch_mypy
1516
- make start
1617
- window_name: docs
1718
layout: main-horizontal

CHANGES

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ $ pip install --user --upgrade --pre libvcs
1616
### What's new
1717

1818
- New and improved logo
19+
- **Improved typings**
20+
21+
Now [`mypy --strict`] compliant ({issue}`390`)
22+
23+
[`mypy --strict`]: https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-strict
24+
1925
- **Parser**: Experimental VCS URL parsing added ({issue}`376`, {issue}`381`, {issue}`384`,
2026
{issue}`386`):
2127

Makefile

+6
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,9 @@ watch_mypy:
5252

5353
format_markdown:
5454
prettier --parser=markdown -w *.md docs/*.md docs/**/*.md CHANGES
55+
56+
monkeytype_create:
57+
poetry run monkeytype run `poetry run which py.test`
58+
59+
monkeytype_apply:
60+
poetry run monkeytype list-modules | xargs -n1 -I{} sh -c 'poetry run monkeytype apply {}'

docs/conf.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import sys
55
from os.path import dirname, relpath
66
from pathlib import Path
7+
from typing import Union
78

89
import libvcs
910

@@ -15,7 +16,7 @@
1516
sys.path.insert(0, str(doc_path / "_ext"))
1617

1718
# package data
18-
about: dict = {}
19+
about: dict[str, str] = {}
1920
with open(project_root / "libvcs" / "__about__.py") as fp:
2021
exec(fp.read(), about)
2122

@@ -58,8 +59,8 @@
5859
html_extra_path = ["manifest.json"]
5960
html_favicon = "_static/favicon.ico"
6061
html_theme = "furo"
61-
html_theme_path: list = []
62-
html_theme_options: dict = {
62+
html_theme_path: list[str] = []
63+
html_theme_options: dict[str, Union[str, list[dict[str, str]]]] = {
6364
"light_logo": "img/libvcs.svg",
6465
"dark_logo": "img/libvcs-dark.svg",
6566
"footer_icons": [
@@ -164,7 +165,9 @@
164165
}
165166

166167

167-
def linkcode_resolve(domain, info): # NOQA: C901
168+
def linkcode_resolve(
169+
domain: str, info: dict[str, str]
170+
) -> Union[None, str]: # NOQA: C901
168171
"""
169172
Determine the URL corresponding to Python object
170173
@@ -197,7 +200,8 @@ def linkcode_resolve(domain, info): # NOQA: C901
197200
except AttributeError:
198201
pass
199202
else:
200-
obj = unwrap(obj)
203+
if callable(obj):
204+
obj = unwrap(obj)
201205

202206
try:
203207
fn = inspect.getsourcefile(obj)

libvcs/_internal/dataclasses.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class SkipDefaultFieldsReprMixin:
7272
ItemWithMixin(name=Test, unit_price=2.05)
7373
"""
7474

75-
def __repr__(self):
75+
def __repr__(self) -> str:
7676
"""Omit default fields in object representation."""
7777
nodef_f_vals = (
7878
(f.name, attrgetter(f.name)(self))

0 commit comments

Comments
 (0)