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) {
197197private string moduleNameFromBase ( Container file ) {
198198 // We used to also require `isPotentialPackage(f)` to hold in this case,
199199 // but we saw modules not getting resolved because their folder did not
200- // contain an `__init__.py` file.
200+ // contain an `__init__.py` file.
201201 //
202202 // 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
203207 //
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.
206213 result = file .getBaseName ( )
207214 or
208215 file instanceof File and result = file .getStem ( )
You can’t perform that action at this time.
0 commit comments