@@ -168,19 +168,25 @@ def find_module(self, id: str) -> ModuleSearchResult:
168
168
169
169
def _find_module_non_stub_helper (self , components : List [str ],
170
170
pkg_dir : str ) -> Union [OnePackageDir , ModuleNotFoundReason ]:
171
- plausible_match = False
171
+ plausible_match = None # type: Optional[Tuple[str, OnePackageDir]]
172
172
dir_path = pkg_dir
173
173
for index , component in enumerate (components ):
174
174
dir_path = os .path .join (dir_path , component )
175
175
if self .fscache .isfile (os .path .join (dir_path , 'py.typed' )):
176
176
return os .path .join (pkg_dir , * components [:- 1 ]), index == 0
177
- elif not plausible_match and (self .fscache .isdir (dir_path )
178
- or self .fscache .isfile (dir_path + ".py" )):
179
- plausible_match = True
180
- if plausible_match :
181
- return ModuleNotFoundReason .FOUND_WITHOUT_TYPE_HINTS
182
- else :
177
+ elif not plausible_match and (
178
+ self .fscache .isfile (os .path .join (dir_path , '__init__.py' ))
179
+ or self .fscache .isfile (dir_path + ".py" )):
180
+ plausible_match = (
181
+ '.' .join (components [:(index + 1 )]),
182
+ (os .path .join (pkg_dir , * components [:- 1 ]), index == 0 )
183
+ )
184
+ if not plausible_match :
183
185
return ModuleNotFoundReason .NOT_FOUND
186
+ elif self .options and plausible_match [0 ] in self .options .pep561_override :
187
+ return plausible_match [1 ]
188
+ else :
189
+ return ModuleNotFoundReason .FOUND_WITHOUT_TYPE_HINTS
184
190
185
191
def _update_ns_ancestors (self , components : List [str ], match : Tuple [str , bool ]) -> None :
186
192
path , verify = match
0 commit comments