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

chore: Configure pre-commit for excluding files through black #7323

Merged
merged 1 commit into from
Oct 6, 2020

Conversation

progmatic-99
Copy link
Contributor

Fixes #7097

Short description of what this resolves:

I hard-coded the files/folders that needs to be excluded in the pre-commit config file. Now, when you run black -v . black ignores the excluded folders/files.

@codecov
Copy link

codecov bot commented Oct 5, 2020

Codecov Report

Merging #7323 into development will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##           development    #7323   +/-   ##
============================================
  Coverage        64.09%   64.09%           
============================================
  Files              259      259           
  Lines            13102    13102           
============================================
  Hits              8398     8398           
  Misses            4704     4704           

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 c4a9bb4...75ea716. Read the comment docs.

@iamareebjamal
Copy link
Member

Ideally it should read the config. Any doc mentioning this is how it should be configured?

@progmatic-99
Copy link
Contributor Author

progmatic-99 commented Oct 5, 2020

https://pre-commit.com/#pre-commit-configyaml---hooks
So, this answer helps a lot as to why we should do it this way, because of the way black works.
This comment also says to use this way to exclude/include files.
As to why black doesn't see the config when run through pre-commit, this issue says that it's consistent behaviour.
The docs or readme doesn't have any reference on why we should do it this way.

@iamareebjamal
Copy link
Member

This

[tool.black]
line-length = 90
target-version = ['py37']
skip-string-normalization = true
exclude = '''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| migrations
)/
| foo.py # also separately exclude a file named foo.py in
# the root of the project
)
'''

@progmatic-99
Copy link
Contributor Author

@iamareebjamal i edited my comment, please review

@iamareebjamal iamareebjamal changed the title Configure pre-commit for excluding files through black chore: Configure pre-commit for excluding files through black Oct 6, 2020
@auto-label auto-label bot added the chore label Oct 6, 2020
@iamareebjamal iamareebjamal merged commit 6edac0f into fossasia:development Oct 6, 2020
@iamareebjamal
Copy link
Member

Thank You

@progmatic-99 progmatic-99 deleted the fix-issue-7097 branch October 7, 2020 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Black in pre-commit applying changes to migrations
2 participants