@@ -142,11 +142,14 @@ def find_stubs_in_paths(paths: Sequence[str]) -> list[str]:
142
142
143
143
144
144
def get_missing_modules (files_to_test : Sequence [str ]) -> Iterable [str ]:
145
- """Gets module names provided by typeshed-external dependencies .
145
+ """Get names of modules that should be treated as missing .
146
146
147
147
Some typeshed stubs depend on dependencies outside of typeshed. Since pytype
148
148
isn't able to read such dependencies, we instead declare them as "missing"
149
149
modules, so that no errors are reported for them.
150
+
151
+ Similarly, pytype cannot parse files on its exclude list, so we also treat
152
+ those as missing.
150
153
"""
151
154
stub_distributions = set ()
152
155
for fi in files_to_test :
@@ -165,6 +168,17 @@ def get_missing_modules(files_to_test: Sequence[str]) -> Iterable[str]:
165
168
top_level_file = os .path .join (egg_info , "top_level.txt" )
166
169
with open (top_level_file ) as f :
167
170
missing_modules .update (f .read ().splitlines ())
171
+ test_dir = os .path .dirname (__file__ )
172
+ exclude_list = os .path .join (test_dir , "pytype_exclude_list.txt" )
173
+ with open (exclude_list ) as f :
174
+ excluded_files = f .readlines ()
175
+ for fi in excluded_files :
176
+ if not fi .startswith ("stubs/" ):
177
+ # Skips comments, empty lines, and stdlib files, which are in
178
+ # the exclude list because pytype has its own version.
179
+ continue
180
+ unused_stubs_prefix , unused_pkg , mod_path = fi .split ("/" , 2 ) # pyright: ignore [reportUnusedVariable]
181
+ missing_modules .add (os .path .splitext (mod_path )[0 ])
168
182
return missing_modules
169
183
170
184
0 commit comments