Skip to content

Commit 3b98423

Browse files
committed
Work around mypy quirks
1 parent ebdde3d commit 3b98423

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/pip/_internal/pep425tags.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ def get_abi_tag():
105105
(CPython 2, PyPy)."""
106106
soabi = get_config_var('SOABI')
107107
impl = get_abbr_impl()
108+
abi = None # type: Optional[str]
109+
108110
if not soabi and impl in {'cp', 'pp'} and hasattr(sys, 'maxunicode'):
109111
d = ''
110112
m = ''
@@ -129,8 +131,7 @@ def get_abi_tag():
129131
abi = 'cp' + soabi.split('-')[1]
130132
elif soabi:
131133
abi = soabi.replace('.', '_').replace('-', '_')
132-
else:
133-
abi = None
134+
134135
return abi
135136

136137

@@ -353,6 +354,7 @@ def get_supported(
353354

354355
# Current version, current API (built specifically for our Python):
355356
for abi in abis:
357+
assert abi
356358
for arch in arches:
357359
supported.append(('%s%s' % (impl, versions[0]), abi, arch))
358360

@@ -362,6 +364,7 @@ def get_supported(
362364
if version in {'31', '30'}:
363365
break
364366
for abi in abi3s: # empty set if not Python 3
367+
assert abi
365368
for arch in arches:
366369
supported.append(("%s%s" % (impl, version), abi, arch))
367370

src/pip/_internal/utils/appdirs.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,9 @@ def _get_win_folder_with_ctypes(csidl_name):
239239
if ctypes.windll.kernel32.GetShortPathNameW(buf.value, buf2, 1024):
240240
buf = buf2
241241

242-
return buf.value
242+
# On Python 2, ctypes.create_unicode_buffer().value returns "unicode",
243+
# which isn't the same as str in the annotation above.
244+
return buf.value # type: ignore
243245

244246

245247
if WINDOWS:

src/pip/_internal/utils/misc.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@
6565
except ImportError:
6666
# typing's cast() isn't supported in code comments, so we need to
6767
# define a dummy, no-op version.
68-
def cast(typ, val):
68+
def cast(typ, val): # type: ignore
6969
return val
70-
VersionInfo = None
70+
VersionInfo = None # type: ignore
7171

7272

7373
__all__ = ['rmtree', 'display_path', 'backup_dir',

0 commit comments

Comments
 (0)