kondo icon indicating copy to clipboard operation
kondo copied to clipboard

Does not delete all `__pycache__` directories

Open jwodder opened this issue 1 year ago • 2 comments

It seems that, currently, kondo only deletes __pycache__ directories located in the root of a Python project, but this is not the only place they can occur (and often there isn't even one in the root). A __pycache__ directory can be created in any directory containing a .py file, and .py files can be organized in any arbitrary assortment of directories with any depth.

jwodder avatar Dec 07 '23 13:12 jwodder

Do you have any good resources I could read about python project structures?

For example is it possible to "nest" python projects, or are all directories underneath considered part of the same "project"?

tbillington avatar Dec 07 '23 13:12 tbillington

Do you have any good resources I could read about python project structures?

Not really. In a perfect world, this would all be documented at https://packaging.python.org, but that site is still lacking in many respects after many years.

Note that __pycache__ technically isn't specific to Python "projects" (if you're defining a project as anything more than a quick script) but rather something created by the python interpreter itself when an import statement is processed[^1]; this link seems like a good overview.

[^1]: Unlike in Rust, in Python it's perfectly normal to write code without involving the packaging systems.

For example is it possible to "nest" python projects, or are all directories underneath considered part of the same "project"?

I believe best practice is against trying to nest projects, but there are various ways to abuse some of the tooling to achieve nested projects. However, I don't think I've ever actually seen nested Python projects, and you should be fine with not trying to support such a (mis)feature.

jwodder avatar Dec 07 '23 14:12 jwodder