Closed jsf9k closed 4 months ago
Now that I've created this PR, I think that cisagov/skeleton-generic might be a better home for these changes. What do you think @cisagov/vm-dev?
I don't really understand the heavy overlap with our
pre-commit
configuration here. All of these tools (exceptingmypy
) can just as effectively be run usingpre-commit run --all-files
, more specificallypre-commit run <hook name> --all-files
, or withpre-commit
installed as a git hook it will be run on commit.mypy
is a separate case because of how it interacts when living in a Python venv, but everything else would potentially conflict with ourpre-commit
configuration since there is no version pinning happening here.
You raise a good point. In the interest of documenting the intent behind this PR, these are the types of problems I was trying to solve:
mypy
isn't installed in the local venv (which my editor is using).flake8
isn't installed in the local venv (which my editor is using).yamllint
, but it can't because yamllint
isn't installed in the local venv (which my editor is using).black
will want to make changes. To save time I'd like to go ahead and run black
against the file without leaving my editor. I can't do that because black
isn't installed in the local venv (which my editor is using).I will handle these dependencies locally. I thought this addition might be useful for others, but I can see that it would cause headaches.
🗣 Description
This pull request installs
yamllint
and the Python libraries we use for code linting and formatting.💠Motivation and context
We can expect developers to install non-Python tools locally via their system's package manager, but the Python-based tools are a different case. We provide
requirements*.txt
files to encourage developers to set up a local Python virtual environment (venv), and many editors will make use of that venv when performing syntax checking and the like. It therefore makes sense to go ahead and include inrequirements-dev.txt
any Python tools that we use for formatting and linting of code.yamllint
is useful because there are a lot of YML files in an Ansible role. Includingyamllint
in the virtual environment for developers will allow their editors to syntax-check these files.(Note that installing
mypy
would be even more useful ifpytest-testinfra
were typed, but that is not yet the case. See pytest-dev/pytest-testinfra#619 for more details about that.)I noticed that my editor was complaining about trying to use
mypy
to provide more information but not finding it available, and I verified that installing it in my venv made that complaint go away. That's what started this whole PR effort.🧪 Testing
All automated tests pass. I noticed that my editor was complaining about trying to use
mypy
andyamllint
to provide more information but not finding them available, and I verified that installing them in my venv made the complaints go away.✅ Pre-approval checklist