8000 Better error message when using pyd file as stubgen (#8063) · python/mypy@e05bd1c · GitHub
[go: up one dir, main page]

Skip to content

Commit e05bd1c

Browse files
TH3CHARLieJukkaL
authored andcommitted
Better error message when using pyd file as stubgen (#8063)
Resolves #8035.
1 parent 4e021d9 commit e05bd1c

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

mypy/build.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,9 +2004,11 @@ def parse_file(self) -> None:
20042004
self.path, os.strerror(ioerr.errno))],
20052005
module_with_blocker=self.id)
20062006
except (UnicodeDecodeError, DecodeError) as decodeerr:
2007-
raise CompileError([
2008-
"mypy: can't decode file '{}': {}".format(self.path, str(decodeerr))],
2009-
module_with_blocker=self.id)
2007+
if self.path.endswith('.pyd'):
2008+
err = "mypy: stubgen does not support .pyd files: '{}'".format(self.path)
2009+
else:
2010+
err = "mypy: can't decode file '{}': {}".format(self.path, str(decodeerr))
2011+
raise CompileError([err], module_with_blocker=self.id)
20102012
else:
20112013
assert source is not None
20122014
self.source_hash = compute_hash(source)

test-data/unit/cmdline.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,3 +1458,11 @@ test.py:4: error: Missing type parameters for generic type "_PathLike"
14581458
test.py:4: note: Subscripting classes that are not generic at runtime may require escaping, see https://mypy.readthedocs.io/en/latest/common_issues.html#not-generic-runtime
14591459
test.py:5: error: Missing type parameters for generic type "Queue"
14601460
test.py:5: note: Subscripting classes that are not generic at runtime may require escaping, see https://mypy.readthedocs.io/en/latest/common_issues.html#not-generic-runtime
1461+
1462+
[case testErrorMessageWhenOpenPydFile]
1463+
# cmd: mypy a.pyd
1464+
[file a.pyd]
1465+
# coding: uft-8
1466+
[out]
1467+
mypy: stubgen does not support .pyd files: 'a.pyd'
1468+
== Return code: 2

0 commit comments

Comments
 (0)
0