Add a environment / config variable to ignore certain certain function patterns
bbelderbos opened this issue · comments
Similar to #20 but that is more for linting, with this issue I suggest a config variable to specify one or more patterns to be ignored, for example main.py
or __init__.py
(we've seen long constructors in FastAPI for example).
Not sure if this should work with function names and/or module names. Probably best to ignore minimally so I suggest the former.
Bare bones env variable handling = os.environ
but usually we use an .env
locally in Python. If you go that route I suggest adding the python-dotenv or python-decouple package / dependency, see:
https://pybit.es/articles/how-to-handle-environment-variables-in-python/
Hi @bbelderbos
Thanks for this suggestion 🙂
I've looked at how other tools solve the exclusion feature:
- Black uses an
--exclude
option that's a regular expression for files and directories (can also be set inpyproject.toml
) - Ruff uses an
exclude
setting inpyproject.toml
for file and directory globs - MyPy uses an
exclude
setting inpyproject.toml
that's a regular expression for files and directories
As it's not common to exclude function names and to keep things familiar for most users, I'm proposing to add an --exclude
option for excluding files/directories with a regular expression, and to also support loading this setting from a pyprojec.toml
file.
What do you think?
Thanks for your research on this @robvanderleek, that sounds like a great way to design this. Not urgent for me right now but I think it will be useful feature.
It's a bit like globally ignoring E501 with flake because you might not agree with this long line violation, likewise there might be functions you just don't want to include in this analysis, long init.py constructors come to mind.
/cib
Hi @bbelderbos
It took some time; for now, I've added an --exclude
command-line option.
Together with the functionality to exclude functions using a # nocl
comment, I think this will handle most situations for current users.
Thanks for submitting both issues!
Nice, this will be useful, thanks!