@@ -913,8 +913,8 @@ def __init__(
913913 continue
914914 path = self .find_module_cache .find_module (module , fast_path = True )
915915 if not isinstance (path , str ):
916- raise CompileError (
917- [ f" Failed to find builtin module { module } , perhaps typeshed is broken?" ]
916+ build_error (
917+ f' Failed to find builtin module " { module } " , perhaps typeshed is broken?'
918918 )
919919 if is_typeshed_file (options .abs_custom_typeshed_dir , path ) or is_stub_package_file (
920920 path
@@ -923,7 +923,7 @@ def __init__(
923923
924924 raise CompileError (
925925 [
926- f'mypy: "{ os .path .relpath (path )} " shadows library module "{ module } "' ,
926+ f'mypy: error: "{ os .path .relpath (path )} " shadows library module "{ module } "' ,
927927 f'note: A user-defined top-level module with name "{ module } " is not supported' ,
928928 ]
929929 )
@@ -1256,7 +1256,11 @@ def all_imported_modules_in_file(self, file: MypyFile) -> list[tuple[int, str, i
12561256 return res
12571257
12581258 def is_module (self , id : str ) -> bool :
1259- """Is there a file in the file system corresponding to module id?"""
1259+ """Does the given fullname refer to a module?
1260+
1261+ Note: this does not always verify that the module exists and relies on
1262+ previously executed logic in find_module_and_diagnose().
1263+ """
12601264 if id in self .modules :
12611265 # Micro-optimization, if we already found it, it is definitely a module.
12621266 return True
@@ -3158,7 +3162,7 @@ def get_source(self) -> str:
31583162 assert ioerr .errno is not None
31593163 raise CompileError (
31603164 [
3161- "mypy: error: cannot read file '{}': {}" .format (
3165+ "mypy: error: Cannot read file '{}': {}" .format (
31623166 self .path .replace (os .getcwd () + os .sep , "" ),
31633167 os .strerror (ioerr .errno ),
31643168 )
@@ -3167,9 +3171,9 @@ def get_source(self) -> str:
31673171 ) from ioerr
31683172 except (UnicodeDecodeError , DecodeError ) as decodeerr :
31693173 if self .path .endswith (".pyd" ):
3170- err = f"{ self .path } : error: stubgen does not support .pyd files"
3174+ err = f"{ self .path } : error: Stubgen does not support .pyd files"
31713175 else :
3172- err = f"{ self .path } : error: cannot decode file: { str (decodeerr )} "
3176+ err = f"{ self .path } : error: Cannot decode file: { str (decodeerr )} "
31733177 raise CompileError ([err ], module_with_blocker = self .id ) from decodeerr
31743178 elif self .path and self .manager .fscache .isdir (self .path ):
31753179 source = ""
@@ -3791,7 +3795,7 @@ def find_module_and_diagnose(
37913795 # If we can't find a root source it's always fatal.
37923796 # TODO: This might hide non-fatal errors from
37933797 # root sources processed earlier.
3794- raise CompileError ([f" mypy: can't find module ' { id } '" ])
3798+ raise CompileError ([f' mypy: error: Cannot find module " { id } "' ])
37953799 else :
37963800 raise ModuleNotFound
37973801
@@ -3920,7 +3924,7 @@ def module_not_found(
39203924 )
39213925 if target == "builtins" :
39223926 manager .error (
3923- line , " Cannot find ' builtins' module. Typeshed appears broken!" , blocker = True
3927+ line , ' Cannot find " builtins" module. Typeshed appears broken!' , blocker = True
39243928 )
39253929 errors .raise_error ()
39263930 else :
0 commit comments