Skip to content

Format code with black #862

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

Merged
merged 2 commits into from
Nov 20, 2020
Merged

Format code with black #862

merged 2 commits into from
Nov 20, 2020

Conversation

sliverc
Copy link
Member

@sliverc sliverc commented Nov 13, 2020

Fixes #857

Description of the Change

Format code with black.

There are no other code changes then just formatting of the code. I split up configuration and formatting into two different commits so we can still have a functioning blame.

Therefore PLEASE no squash commit on this PR when merging.

Issue which are not directly related to black I will follow up with other PRs:

  • Introduce pre-commit and update contributing
  • remove ignore of F405 error

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added
  • documentation updated
  • CHANGELOG.md updated (only for user relevant changes)
  • author name in AUTHORS

@sliverc sliverc requested a review from n2ygk November 13, 2020 16:05
@codecov
Copy link

codecov bot commented Nov 13, 2020

Codecov Report

Merging #862 (0146890) into master (1e2594f) will not change coverage.
The diff coverage is 98.31%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #862   +/-   ##
=======================================
  Coverage   97.74%   97.74%           
=======================================
  Files          60       60           
  Lines        3319     3319           
=======================================
  Hits         3244     3244           
  Misses         75       75           
Impacted Files Coverage Δ
example/api/serializers/post.py 100.00% <ø> (ø)
example/migrations/0007_artproject_description.py 100.00% <ø> (ø)
.../tests/integration/test_non_paginated_responses.py 100.00% <ø> (ø)
example/tests/integration/test_pagination.py 100.00% <ø> (ø)
rest_framework_json_api/relations.py 88.40% <87.50%> (ø)
rest_framework_json_api/metadata.py 91.66% <88.46%> (ø)
rest_framework_json_api/renderers.py 90.18% <90.54%> (ø)
example/api/resources/identity.py 100.00% <100.00%> (ø)
example/api/serializers/identity.py 100.00% <100.00%> (ø)
example/factories.py 100.00% <100.00%> (ø)
... and 48 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 1e2594f...0146890. Read the comment docs.

Copy link
Contributor

@n2ygk n2ygk left a comment

Choose a reason for hiding this comment

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

Sorry it took me so long to get to this.

If you can make sure auto-generated files are not reformatted, that would be great. Otherwise we'll have a bunch unnecessary diffs.

@@ -15,7 +15,6 @@

import datetime
import os
import shlex
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add this to an exceptions file that black won't fix? conf.py is autogenerated by sphinx-quickstart and then edited manually after that.

@@ -2,93 +2,154 @@
# Generated by Django 1.9.5 on 2016-05-02 08:26
Copy link
Contributor

Choose a reason for hiding this comment

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

As above, exclude migrations.

@@ -4,116 +4,97 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

Also exclude auto-generated snapshots

@sliverc
Copy link
Member Author

sliverc commented Nov 20, 2020

Thanks for having a look at this.

I deliberately formatted the generated files as well because:

  • the Django Enhancement Proposal DEP-8 specifies it this way

All code Django generates will also be Black-formatted (startproject, migrations, inspectdb, etc.), at least if the user has Black installed.

  • this allows us to enable linting on generated files as most of the generated files actually are edited by humans - this way human error can be minimized. (e.g. migrations can also have user input if a manual migration needs to be written).

Does this makes sense?

@n2ygk n2ygk merged commit d8f26fc into django-json-api:master Nov 20, 2020
@sliverc sliverc deleted the black branch November 20, 2020 19:42
@sliverc sliverc mentioned this pull request Dec 11, 2020
5 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.

Format code with black
2 participants