ansible-collections / cisco.asa

Ansible Security Collection for Cisco ASA
GNU General Public License v3.0
60 stars 46 forks source link

Add PyProject.toml for Black Configuration #51

Open jvanderaa opened 4 years ago

jvanderaa commented 4 years ago
SUMMARY

Running black executable should format python as expected.

ISSUE TYPE
COMPONENT NAME

black

ANSIBLE VERSION
Python, not Ansible issue
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
  1. Run black . which reformats the documents
  2. Submit PR
  3. Tox fails due to line length differing from 88 characters that defaults in black, tox has manual configuration of 79 char length
EXPECTED RESULTS

black . would reformat all Python files as expected

ACTUAL RESULTS

Reformat works, tox linter fails in Zuul

/cisco.asa/plugins/modules/asa_og.py
All done! 💥 💔 💥
1 file would be reformatted, 66 files would be left unchanged.
Qalthos commented 4 years ago

So of note is that the line length is not the only variable at hand.

We explicitly use version 19.3b0 of black, because the latest version changes the output significantly enough to hold back. So specifying the line length isn't sufficient to ensure output passes tox tests.

As such, the supported way of making sure your files are correctly formatted is with tox -e black which will fetch and run the correct version of black, and tox -e linters which will also run flake8, but only report errors and not make any changes.

This request has merit, and specifying line length in pyproject.toml does mean we don't have to specify it in tox.ini, but it isn't likely to happen without coordinated changes across all supported collections.

jvanderaa commented 4 years ago

Makes sense. Within my development practices, and I can be convinced to change, but I often would do just black . to run and allow the configuration file in the project repo handle the settings involved. That is for just black specifically however. I get there is a bunch more at play as well. I can submit a base one if you would like, or proceed however it may look to get across the board. That is something that I don't have line of sight to that you have a much better viewpoint on.