Skip to content

Commit 4db11f7

Browse files
committed
dev: fix type checking with mypy
1 parent 89ccd32 commit 4db11f7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/cookiecutter_python/hooks/pre_gen_project.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import re
22
import sys
3+
from typing import Callable, Union
4+
5+
6+
is_python_package: Union[Callable[[str], bool], None]
7+
38

49
try:
510
from ask_pypi import is_pypi_project
11+
is_python_package = is_pypi_project
612
except ImportError:
7-
is_pypi_project = None
13+
is_python_package = None
814

915

1016
# Templated Variables should be centralized here for easier inspection
@@ -36,9 +42,9 @@ def check_version_is_semver(version: str):
3642

3743

3844
def available_package_name(package_name: str) -> str:
39-
if is_pypi_project:
45+
if is_python_package is not None:
4046
try:
41-
return {True: 'not-available', False: 'available'}[is_pypi_project(package_name)]
47+
return {True: 'not-available', False: 'available'}[is_python_package(package_name)]
4248
except Exception as error: # ie network failure
4349
print(str(error), file=sys.stderr)
4450
return 'unknown'

0 commit comments

Comments
 (0)