Dev Environment: Makemigrations Files Fails Linting Tests
See original GitHub issueEnvironment
- Python version: Development Environment
- Nautobot version: 1.0.0b2
Steps to Reproduce
- Update models that create a migration
- Run
invoke build
- Run
invoke makemigrations
- File is created with root:root user account
- Black is unable to run
- File does not meet black standards (I know, Django doing it, not the project)
Expected Behavior
Expected a migration file to pass linting without needing additional steps
Observed Behavior
Files had to have ownership changed to be able to blacken the file, then needing to black.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
3YOURMIND/django-migration-linter - GitHub
The linter analysed all migrations from the Django project. It found 3 migrations that are doing backward incompatible operations and 1 that is...
Read more >Testing Django Migrations - sobolevn.me
We lint migration files with wemake-python-styleguide , it drastically reduces the possibility of bad code inside the migration files; We use ...
Read more >django-migration-linter - PyPI
Detect backward incompatible migrations for your django project.
Read more >Set up tests, linters and type checking in Python projects in 2020
Set up tests, linters and type checking in Python projects in 2020 · Before starting · Testing · Code coverage · Linting ·...
Read more >Database creation failing during django testing - Stack Overflow
I don't think that's a good idea tbh, django migrations are very picky and might need a full database reboot if things get...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t really have an issue w/ excluding migrations from
black
seeing as the majority of them are automatically generated, but I do have an issue with the motivation for it being that we have two supported development patterns, and one of them isn’t playing nicely.As discussed above, this issue describes two distinct problems:
For item 1, this is an annoyance but easy enough to solve by running Black against the migrations after they are generated. Since we don’t have any control over the code generated by Django, the only other option would be to exclude migrations from Black’s checking, and after some discussion amongst the core team we don’t feel that doing that would be desirable. The benefit of having consistent code style across the entire project, including migrations, outweighs the inconvenience.
For item 2, this is a notable flaw in the current Docker development environment. More discussion amongst the core team revealed that most of the core team are not actually using the Docker development environment but instead a hybrid virtualenv + Docker services environment that’s not currently documented as a workflow, but avoids the file permissions issue naturally. I’ve opened #507 to track the work needed to document this hybrid workflow as the actual, preferred development workflow for Nautobot.
Thank you for opening this issue - it sparked some important conversations!