File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
python/ql/lib/semmle/python Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -197,12 +197,19 @@ private predicate isPotentialPackage(Folder f) {
197
197
private string moduleNameFromBase ( Container file ) {
198
198
// We used to also require `isPotentialPackage(f)` to hold in this case,
199
199
// but we saw modules not getting resolved because their folder did not
200
- // contain an `__init__.py` file.
200
+ // contain an `__init__.py` file.
201
201
//
202
202
// This makes the folder not be a package but a namespace package instead.
203
+ // In most cases this is a mistake :| See following links for more details
204
+ // - https://dev.to/methane/don-t-omit-init-py-3hga
205
+ // - https://packaging.python.org/en/latest/guides/packaging-namespace-packages/
206
+ // - https://discuss.python.org/t/init-py-pep-420-and-iter-modules-confusion/9642
203
207
//
204
- // It is possible that we can keep the requirement here, but relax
205
- // `isPotentialPackage` itself to allow for namespace packages.
208
+ // It is possible that we can keep the original requirement on
209
+ // `isPotentialPackage(f)` here, but relax `isPotentialPackage` itself to allow
210
+ // for this behavior of missing `__init__.py` files. However, doing so involves
211
+ // cascading changes (for example to `moduleNameFromFile`), and was a more involved
212
+ // task than we wanted to take on.
206
213
result = file .getBaseName ( )
207
214
or
208
215
file instanceof File and result = file .getStem ( )
You can’t perform that action at this time.
0 commit comments