feat: Check for __all__ presence in __init__.py files#766
feat: Check for __all__ presence in __init__.py files#766AcquaDiGiorgio wants to merge 4 commits intoDIRACGrid:mainfrom
Conversation
fix: Exclude automatically generated __init__ files
.pre-commit-config.yaml
Outdated
| name: Check for __all__ presence in __init__.py files | ||
| language: system | ||
| entry: "sh .github/workflows/check_init_files_precommit_hook.sh" | ||
| files: ^diracx-.*__init__\.py$ |
There was a problem hiding this comment.
I think you need to exclude the auto-generated part of diracx-client from this i.e.
https://github.com/DIRACGrid/diracx/tree/main/diracx-client/src/diracx/client/_generated
I guess this should also apply to the example extension (gubbins):
https://github.com/DIRACGrid/diracx/tree/main/extensions/gubbins
There was a problem hiding this comment.
The regex only applies for files that start with diracx-, so the extensions directory won't be searched.
Also, with the exclude: _generated in the next line, it already ignores the auto-generated files.
With the current configuration, it finds the following files:
diracx-logic/src/diracx/logic/task_queues/__init__.py
diracx-logic/src/diracx/logic/jobs/__init__.py
diracx-logic/src/diracx/logic/auth/__init__.py
diracx-logic/src/diracx/logic/__init__.py
diracx-db/src/diracx/db/sql/dummy/__init__.py
diracx-db/src/diracx/db/sql/job/__init__.py
diracx-db/src/diracx/db/sql/pilot_agents/__init__.py
diracx-db/src/diracx/db/sql/task_queue/__init__.py
diracx-db/src/diracx/db/sql/job_logging/__init__.py
diracx-db/src/diracx/db/sql/sandbox_metadata/__init__.py
diracx-db/src/diracx/db/sql/auth/__init__.py
diracx-db/tests/pilot_agents/__init__.py
diracx-core/src/diracx/core/__init__.py
diracx-routers/src/diracx/routers/utils/__init__.py
diracx-routers/src/diracx/routers/jobs/__init__.py
There was a problem hiding this comment.
Or do you mean that the gubbins extension should be checked too?
There was a problem hiding this comment.
Yes I think they should also be checked indeed
I didn't see any standard way of defining |
There was a problem hiding this comment.
Any specific reason for making a bash script instead of a pixi task as done here:
diracx/.pre-commit-config.yaml
Lines 86 to 102 in 9cc792e
If we want to enforce lists for instance, I have the feeling it would be easier to implement (and also let the possibility of unit testing it if needed).
Any opinion?
There was a problem hiding this comment.
I used bash for the commodity of grep, but I can change the script to use python with pixi instead, it will definetely be much easier/cleaner to check its type that way.
chrisburr
left a comment
There was a problem hiding this comment.
Yet another fake review for me to be able to test something 😄
See #426
I tried something more sofisticated in python using
importlibto check the variables in the module, both instantiated and imported, but there were multiple situations that were extremely difficult to check.We also might want to set a common way of defining this variable, using either tuples or lists:
__all__ = ["router"]__all__ = ("JobParametersDB",)