Skip to content

Commit 0c11cc3

Browse files
committed
fixed mypy errors in setup boilerplate
1 parent cb91912 commit 0c11cc3

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

setup_boilerplate.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import docutils.utils
1818
import setuptools
1919

20-
__updated__ = '2020-01-29'
20+
__updated__ = '2020-02-02'
2121

2222
SETUP_TEMPLATE = '''"""Setup script."""
2323
@@ -84,9 +84,10 @@ def parse_requirements(
8484

8585
def partition_version_classifiers(
8686
classifiers: t.Sequence[str], version_prefix: str = 'Programming Language :: Python :: ',
87-
only_suffix: str = ' :: Only') -> t.Tuple[t.List[str], t.List[str]]:
87+
only_suffix: str = ' :: Only') -> t.Tuple[t.List[t.Sequence[int]], t.List[t.Sequence[int]]]:
8888
"""Find version number classifiers in given list and partition them into 2 groups."""
89-
versions_min, versions_only = [], []
89+
versions_min: t.List[t.Sequence[int]] = []
90+
versions_only: t.List[t.Sequence[int]] = []
9091
for classifier in classifiers:
9192
version = classifier.replace(version_prefix, '')
9293
versions = versions_min
@@ -148,6 +149,7 @@ def __init__(self, *args, **kwargs):
148149

149150
def visit_reference(self, node: docutils.nodes.reference) -> None:
150151
"""Call for "reference" nodes."""
152+
assert isinstance(node, docutils.nodes.TextElement), type(node)
151153
if len(node.children) != 1 or not isinstance(node.children[0], docutils.nodes.Text) \
152154
or not all(_ in node.attributes for _ in ('name', 'refuri')):
153155
return
@@ -229,8 +231,8 @@ class Package:
229231
packages = None # type: t.List[str]
230232
"""If None, determined with help of setuptools."""
231233

232-
package_data = {}
233-
exclude_package_data = {}
234+
package_data = {} # type: t.Dict[str, t.List[str]]
235+
exclude_package_data = {} # type: t.Dict[str, t.List[str]]
234236

235237
install_requires = None # type: t.List[str]
236238
"""If None, determined using requirements.txt."""
@@ -259,14 +261,14 @@ def try_fields(cls, *names) -> t.Optional[t.Any]:
259261
raise AttributeError((cls, names))
260262

261263
@classmethod
262-
def parse_readme(cls, readme_path: str = 'README.rst',
264+
def parse_readme(cls, readme_filename: str = 'README.rst',
263265
encoding: str = 'utf-8') -> t.Tuple[str, str]:
264266
"""Parse readme and resolve relative links in it if it is feasible.
265267
266268
Links are resolved if readme is in rst format and the package is hosted on GitHub.
267269
"""
268-
readme_path = pathlib.Path(readme_path)
269-
with HERE.joinpath(readme_path).open(encoding=encoding) as readme_file:
270+
readme_path = HERE.joinpath(readme_filename)
271+
with readme_path.open(encoding=encoding) as readme_file:
270272
long_description = readme_file.read() # type: str
271273

272274
if readme_path.suffix.lower() == '.rst' and cls.url.startswith('https://github.com/'):

0 commit comments

Comments
 (0)