File tree 1 file changed +9
-6
lines changed 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -152,12 +152,15 @@ def find_stubs_in_paths(paths: Sequence[str]) -> list[str]:
152
152
def _get_pkgs_associated_with_requirement (req_name : str ) -> list [str ]:
153
153
dist = importlib .metadata .distribution (req_name )
154
154
toplevel_txt_contents = dist .read_text ("top_level.txt" )
155
- if toplevel_txt_contents is not None :
156
- return toplevel_txt_contents .split ()
157
- if dist .files is None :
158
- raise RuntimeError ("Can't read find the packages associated with requirement {req_name!r}" )
159
- maybe_modules = [f .parts [0 ] if len (f .parts ) > 1 else inspect .getmodulename (f ) for f in dist .files ]
160
- return [name for name in maybe_modules if name is not None and "." not in name ]
155
+ if toplevel_txt_contents is None :
156
+ if dist .files is None :
157
+ raise RuntimeError ("Can't read find the packages associated with requirement {req_name!r}" )
158
+ maybe_modules = [f .parts [0 ] if len (f .parts ) > 1 else inspect .getmodulename (f ) for f in dist .files ]
159
+ packages = [name for name in maybe_modules if name is not None and "." not in name ]
160
+ else :
161
+ packages = toplevel_txt_contents .split ()
162
+ # https://peps.python.org/pep-0561/#stub-only-packages
163
+ return sorted ({package .removesuffix ("-stubs" ) for package in packages })
161
164
162
165
163
166
def get_missing_modules (files_to_test : Sequence [str ]) -> Iterable [str ]:
You can’t perform that action at this time.
0 commit comments