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

Applied isort and black to project #180

Closed
wants to merge 4 commits into from
Closed

Conversation

smithdc1
Copy link
Contributor

@smithdc1 smithdc1 commented Dec 6, 2020

We want to make the sort order of imports uniform across all modules, and so do we want to unify the coding style as such.

This is a follow-up of #152 (comment).

@codecov
Copy link

codecov bot commented Dec 6, 2020

Codecov Report

Merging #180 (e708d01) into master (8cd75d9) will not change coverage.
The diff coverage is 88.95%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #180   +/-   ##
=======================================
  Coverage   94.25%   94.25%           
=======================================
  Files          29       29           
  Lines        1270     1270           
=======================================
  Hits         1197     1197           
  Misses         73       73           
Impacted Files Coverage Δ
analytical/templatetags/yandex_metrica.py 82.35% <61.53%> (ø)
analytical/templatetags/uservoice.py 80.95% <66.66%> (ø)
analytical/templatetags/mixpanel.py 90.24% <70.00%> (ø)
analytical/templatetags/kiss_insights.py 94.11% <80.00%> (ø)
analytical/templatetags/rating_mailru.py 91.30% <80.00%> (ø)
analytical/templatetags/gauges.py 91.30% <83.33%> (ø)
analytical/templatetags/google_analytics_gtag.py 93.10% <83.33%> (ø)
analytical/templatetags/gosquared.py 91.17% <83.33%> (ø)
analytical/templatetags/optimizely.py 91.30% <83.33%> (ø)
analytical/templatetags/chartbeat.py 89.28% <85.71%> (ø)
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8cd75d9...e708d01. Read the comment docs.

analytical/templatetags/chartbeat.py Outdated Show resolved Hide resolved
Comment on lines 13 to 17
'<script type="text/javascript" src="{placeholder_url}">'
"</script>".format(
placeholder_url="//dnn506yrbagrg.cloudfront.net/pages/scripts/"
"%(account_nr_1)s/%(account_nr_2)s.js"
)
Copy link
Member

Choose a reason for hiding this comment

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

I can't help but saying, don't you feel this is harder to read? 😟 Man, Black, a hard time getting used to your style.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I rewrote this a little bit, there's a lot going on here. Hopefully the way I have refactored is correct, and is a bit more readable.

Copy link
Member

Choose a reason for hiding this comment

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

The tests will hopefully prove that your refactoring was successful! 😄 🤞

analytical/templatetags/google_analytics.py Outdated Show resolved Hide resolved
@@ -39,11 +42,11 @@

VARIABLE_CODE = '_paq.push(["setCustomVariable", %(index)s, "%(name)s", "%(value)s", "%(scope)s"]);' # noqa
IDENTITY_CODE = '_paq.push(["setUserId", "%(userid)s"]);'
DISABLE_COOKIES_CODE = '_paq.push([\'disableCookies\']);'
DISABLE_COOKIES_CODE = "_paq.push(['disableCookies']);"
Copy link
Member

Choose a reason for hiding this comment

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

That one I like! But, yeah, that was an easy one.

IDENTITY_CODE % {'userid': userid},
))
variables_code = chain(
variables_code, (IDENTITY_CODE % {"userid": userid},)
Copy link
Member

Choose a reason for hiding this comment

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

Wow! This is horribly difficult to understand!

setup.cfg Outdated Show resolved Hide resolved
Comment on lines 21 to 24
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
)
Copy link
Member

Choose a reason for hiding this comment

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

Oh! We should really convert this to the new-style MIDDLEWARE, e.g.

MIDDLEWARE = [
    "django.middleware.common.CommonMiddleware",
    "django.middleware.csrf.CsrfViewMiddleware",
]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one sounds like it should be a separate PR? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Weh-eh-ell, that sounds like that should have been done earlier! 😏

Didn't anyone write a linter for that yet? Maybe we should extend flake8-django to check on a list being used for MIDDLEWARE and INSTALLED_APPS.

Copy link
Member

Choose a reason for hiding this comment

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

Voilà! 🎸

tests/unit/test_tag_chartbeat.py Outdated Show resolved Hide resolved
@@ -8,6 +8,7 @@
from django.http import HttpRequest
from django.template import Context
from django.test.utils import override_settings
from utils import TestCase
Copy link
Member

Choose a reason for hiding this comment

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

All these utils imports are really "local" imports. I hope we won't get bitten by them, one day. It may make sense to convert all them to relative imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This sounds like a separate PR to me?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, this one does. 💯

tox.ini Outdated Show resolved Hide resolved
@smithdc1
Copy link
Contributor Author

smithdc1 commented Dec 7, 2020

I see the project has flake8 line length set at 100. I'm not sure how you feel about letting black use this as well?

I'll have a look again through the project and move a few commas about, that may help a little.

@bittner
Copy link
Member

bittner commented Dec 7, 2020

I see the project has flake8 line length set at 100. I'm not sure how you feel about letting black use this as well?

Do you intend, instead of the default 88?

I don't know. I think I picked the 100 in the past when I introduced flake8 in this project (I think I did) just to make sure we can activate it hard in Tox/Travis more easily. It's not really an indicator of how strict or not the coding style is. Now that black is going to rule the project everything's different anyway. Feel free to make whatever choice you deem vital.

Copy link
Member

@bittner bittner left a comment

Choose a reason for hiding this comment

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

Now we're doomed! 💣 💥

Would it make more sense to start over again with all the conflicts we have since merging the "plain assert" PR? 😔

@smithdc1 smithdc1 closed this Feb 18, 2021
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.

2 participants