Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add black job #42

Merged
merged 6 commits into from
Dec 3, 2019
Merged

Add black job #42

merged 6 commits into from
Dec 3, 2019

Conversation

giovana-morais
Copy link
Contributor

References issue #38

Changes:

  • Add black to dev_requirements.txt, .pre-commit-config.yaml, .travis.yml and tox.ini
  • Update source files after black reformatted them

Now I need help with two import statements that flake8 claims are unused. One of them is in the file test_recipes.py (from random import choices) and the other one is in the file test_filling_fields.py (from django.core.files import images, File).

I tried commenting both imports and building it on Travis and the build failed for the random import, so I just kept django import commented, and used SKIP=flake8,pydocstyle before my commit. After that the build worked just fine, but if I try to run flake8, it will fail with the test_filling_fields.py. Any ideas?

@anapaulagomes
Copy link
Contributor

Hey @giovana-morais, just a heads up: I'm super busy lately but in a few days I'll be able to review your PR. Please bear with me. :)

@berinhard berinhard closed this Dec 2, 2019
@berinhard berinhard reopened this Dec 2, 2019
Copy link
Member

@berinhard berinhard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@giovana-morais thanks for your PR! I ran the flake8 command using the code from your branch and my ouput was:

(model_bakery) [bernardo@capibaribe ~/envs/model_bakery(add_black_job)]$ flake8
./tests/test_recipes.py:4:1: F401 'random.choice' imported but unused
from random import choice
^
1     F401 'random.choice' imported but unused

I saw you've com@giovana-morais thanks for your PR! I ran the flake8 command using the code from your branch and my ouput was:

(model_bakery) [bernardo@capibaribe ~/envs/model_bakery(add_black_job)]$ flake8
./tests/test_recipes.py:4:1: F401 'random.choice' imported but unused
from random import choice
^
1     F401 'random.choice' imported but unused

And you're right about the tests starting to break if we remove this import. The issue is with 2 tests that were poorly when it comes to using Python's mock module. I don't think it's worthwhile for us to fix these tests for now. Instead you can turn of Flake8 for this specific import line by changing it to:

from random import choice

To

from random import choice  # noqa

After doing that, I was able to run Flake8 lint with success =]

tests/test_filling_fields.py Outdated Show resolved Hide resolved
@giovana-morais
Copy link
Contributor Author

hey @berinhard ! thanks for the tip about # noqa. i'll add it today and also remove the commented line (i didn't know if it was important, so i kept it) tonight.

@giovana-morais
Copy link
Contributor Author

I think now eveything is okay. Both black and flake8 were able to do the tests without crashing each other. 😌 Can you guys give it a double check? @berinhard @anapaulagomes

@berinhard
Copy link
Member

Thanks @giovana-morais! Merging it right away!

@berinhard berinhard merged commit da05ee0 into model-bakers:master Dec 3, 2019
Copy link
Contributor

@anapaulagomes anapaulagomes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done, @giovana-morais! 🎉

Don't make baker sad." % str(item))
raise ValueError(
"Required value '%s' is of wrong type. \
Don't make baker sad."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we couldn't have made it one line. 🤔

@anapaulagomes anapaulagomes mentioned this pull request Dec 5, 2019
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants