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

Read configuration from pyproject.toml #58

Merged
merged 27 commits into from
Sep 2, 2020
Merged

Read configuration from pyproject.toml #58

merged 27 commits into from
Sep 2, 2020

Conversation

akaihola
Copy link
Owner

Also dumps configuration on terminal if debug level logging is enabled with the -vv or --verbose --verbose command line option.

@akaihola akaihola added the enhancement New feature or request label Aug 16, 2020
@akaihola akaihola added this to the 1.2.0 milestone Aug 16, 2020
@akaihola akaihola self-assigned this Aug 16, 2020
@akaihola akaihola added this to In progress in Akaihola's Open source work via automation Aug 16, 2020
@akaihola akaihola linked an issue Aug 16, 2020 that may be closed by this pull request
1 task
@akaihola
Copy link
Owner Author

I'm drafting a blog post about using darker and pytest-darker together. I realized that the setup I'm going to describe there will require the ability to use a configuration file configure how Darker is run.

@akaihola
Copy link
Owner Author

@Carreau, are you interested to review this?

(I still can't assign you as a reviewer in the GitHub UI since you haven't accepted the invitation to join as a collaborator. Do you want me to cancel the invitation?)

@Carreau
Copy link
Collaborator

Carreau commented Aug 19, 2020

Sorry I missed the invitation, it has expired now.

@Carreau
Copy link
Collaborator

Carreau commented Aug 19, 2020

did a quick read through, look good to me. I'll look at the blog post.

@Carreau
Copy link
Collaborator

Carreau commented Aug 19, 2020

On the blog post, maybe extend to why one might not want to run darker on that full code base at once.

Also add that with darker enabled the codebase will thus slowly converge to a point where all code is comformant in the limit of all lines having changed.

Also dumps configuration on terminal if debug level logging is enabled
with the `-vv` or `--verbose --verbose` command line option.
src/darker/command_line.py Outdated Show resolved Hide resolved
src/darker/config.py Outdated Show resolved Hide resolved
@akaihola akaihola requested a review from Carreau August 19, 2020 20:00
Also:
- clean lru_cache from the `black.find_project_root()` function in
  unit tests
- add unit test for handling of positional command line arguments
  defined in configuration
pyproject.toml Outdated Show resolved Hide resolved
src/darker/config.py Outdated Show resolved Hide resolved
Fails to build wheels for
- `regex`
- `typed-ast`
- `wrapt`
- `lazy-object-proxy`
@akaihola
Copy link
Owner Author

@Carreau I did some major fixes after your review. Do you have time to review again, or would you prefer other contributors to join?

@Carreau
Copy link
Collaborator

Carreau commented Aug 26, 2020

Do you have time to review again, or would you prefer other contributors to join?

I'll try to do that now.

@Carreau
Copy link
Collaborator

Carreau commented Aug 26, 2020

Looks good, one suggestion about print()/dumps_config, and one concern about making finding project root without a src

src/darker/config.py Outdated Show resolved Hide resolved
src/darker/__main__.py Show resolved Hide resolved
The tests broke with the Darker 20.8 update because of the changed
formatting rules and the fact that we generated test data using
Black. The test data is now hard-coded.
Only if no paths are given on the command line, try to load
`pyproject.toml` in the Git root above current working directory, and
use the `src =` option from there if available.
@akaihola
Copy link
Owner Author

Ok @Mystic-Mirage now the build in this branch succeeds. We have mixed Black 19.10/20.8 formatting in the code base, and CI only requires Black 20.8 formatting for lines modified in merge requests.

In a way, Darker is now eating its own dogfood 🐶

Could we merge this instead of #62 in your opinion?

src/darker/command_line.py Show resolved Hide resolved
src/darker/config.py Show resolved Hide resolved
src/darker/config.py Show resolved Hide resolved
src/darker/config.py Show resolved Hide resolved
src/darker/config.py Show resolved Hide resolved
src/darker/config.py Show resolved Hide resolved
src/darker/config.py Show resolved Hide resolved
src/darker/command_line.py Show resolved Hide resolved
src/darker/command_line.py Show resolved Hide resolved
src/darker/black_diff.py Show resolved Hide resolved
@sourcery-ai
Copy link

sourcery-ai bot commented Sep 2, 2020

Sourcery Code Quality Report (beta)

❌  Merging this PR will decrease code quality in the affected files by 0.08 out of 10.

Quality metrics Before After Change
Complexity 1.79 1.76 -0.03 🔵
Method Length 68.81 77.76 8.95 🔴
Quality 8.32 8.24 -0.08 🔴
Other metrics Before After Change
Lines 1040 1380 340
Changed files Quality Before Quality After Quality Change
src/darker/main.py 7.39 7.34 -0.05 🔴
src/darker/argparse_helpers.py 9.25 9.01 -0.24 🔴
src/darker/black_diff.py 8.15 8.25 0.10 🔵
src/darker/command_line.py 7.73 7.85 0.12 🔵
src/darker/linting.py 8.08 8.08 0.00
src/darker/tests/conftest.py 9.21 9.27 0.06 🔵
src/darker/tests/test_command_line.py 8.49 7.98 -0.51 🔴
src/darker/tests/test_diff.py 8.23 8.22 -0.01 🔴
src/darker/tests/test_linting.py 7.74 7.73 -0.01 🔴

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Overall Recommendation
src/darker/main.py format_edited_parts 22 226.89 3.87 Split out functionality
src/darker/main.py main 16 210.79 4.54 Split out functionality
src/darker/tests/test_command_line.py test_parse_command_line 4 466.77 4.69 Split out functionality
src/darker/command_line.py make_argument_parser 3 222.30 5.68 Split out functionality
src/darker/tests/test_command_line.py test_black_options 0 193.48 6.26 Split out functionality

Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Let us know what you think of it by mentioning @sourcery-ai in a comment.

@akaihola akaihola merged commit cc414a0 into master Sep 2, 2020
Akaihola's Open source work automation moved this from In progress to Done Sep 2, 2020
@akaihola akaihola deleted the config-file branch September 2, 2020 18:09
@akaihola
Copy link
Owner Author

@Carreau, I continued the blog post draft – what do you think about it now?

@akaihola
Copy link
Owner Author

I've now published the blog post Improving Python code incrementally on dev.to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Configuration file(s)
3 participants