Skip to content

Commit 5e94da9

Browse files
committed
+typing
1 parent bb8fc74 commit 5e94da9

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ setup.py
33
README.rst
44
.pytest_cache/
55
*.egg-info
6+
.mypy_cache/

dephell_changelogs/_finder.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ def _get_changelog_pypi(parsed: ParseResult) -> Optional[str]:
159159

160160

161161
def _get_changelog_rtfd(parsed: ParseResult) -> Optional[str]:
162+
if parsed.hostname is None:
163+
return None
162164
project_name = parsed.hostname.split('.', maxsplit=1)[0]
163165
if project_name in KNOWN_CHANGELOGS:
164166
return KNOWN_CHANGELOGS[project_name]
@@ -186,6 +188,8 @@ def get_changelog_url(base_url: str) -> Optional[str]:
186188

187189
# fast checks for URL
188190
parsed = urlparse(base_url)
191+
if parsed.hostname is None:
192+
return None
189193
if not _known_domain(parsed.hostname):
190194
return None
191195
response = requests.head(base_url)
@@ -196,6 +200,8 @@ def get_changelog_url(base_url: str) -> Optional[str]:
196200
# get hostname
197201
parsed = urlparse(base_url)
198202
hostname = parsed.hostname
203+
if hostname is None:
204+
return None
199205
if hostname.startswith('www.'):
200206
hostname = hostname[4:]
201207

dephell_changelogs/_parser.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# built-in
22
import re
3-
from typing import Dict, Optional
3+
from typing import Dict, List, Optional
44

55
# external
66
import requests
@@ -55,9 +55,9 @@ def parse_changelog(content: str) -> Dict[str, str]:
5555
response.raise_for_status()
5656
content = response.text
5757

58-
changelog = dict()
59-
version = None
60-
notes = []
58+
changelog = dict() # type: Dict[str, str]
59+
version = 'unknown'
60+
notes = [] # type: List[str]
6161
for line in content.splitlines():
6262
# drop rst-like header from the section beginning
6363
if not notes:

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ envs = ["main", "dev"]
99
tests = ["tests"]
1010
command = "python -m pytest -n 4 tests/"
1111

12+
[tool.dephell.typing]
13+
from = {format = "flit", path = "pyproject.toml"}
14+
envs = ["main", "dev"]
15+
command = "mypy --ignore-missing-imports --allow-redefinition dephell_changelogs"
16+
1217

1318
[tool.flit.metadata]
1419
module="dephell_changelogs"

0 commit comments

Comments
 (0)