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

Fix gen_python_files usage for black>=21.7b1.dev9 #189

Merged
merged 4 commits into from
Sep 4, 2021

Conversation

flying-sheep
Copy link
Collaborator

This should fix the tests and be backwards compatible

@akaihola
Copy link
Owner

akaihola commented Sep 3, 2021

As noted by @flying-sheep, I already had a fix for this in #183. The difference is that my solution looks at black.__version__ and this one inspects the actual signature of the function. Is this just a matter of taste or do you see pros and cons in each approach?

src/darker/black_diff.py Outdated Show resolved Hide resolved
src/darker/black_diff.py Outdated Show resolved Hide resolved
src/darker/black_diff.py Outdated Show resolved Hide resolved
@akaihola
Copy link
Owner

akaihola commented Sep 3, 2021

Could you add a change log entry similar to the one in the alternative pull request?

Copy link
Owner

@akaihola akaihola left a comment

Choose a reason for hiding this comment

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

You can see a couple of comments in the review. I'm starting to think I like the inspect approach better than looking at the Black version.

@akaihola akaihola changed the title Fix gen_python_files usage for black>=21.8b0 Fix gen_python_files usage for black>=21.7b1.dev9 Sep 3, 2021
@akaihola akaihola added the bug Something isn't working label Sep 3, 2021
@akaihola akaihola added this to the 1.3.0 milestone Sep 3, 2021
@sourcery-ai
Copy link

sourcery-ai bot commented Sep 3, 2021

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.44%.

Quality metrics Before After Change
Complexity 3.91 ⭐ 3.83 ⭐ -0.08 👍
Method Length 68.75 🙂 74.75 🙂 6.00 👎
Working memory 6.59 🙂 6.74 🙂 0.15 👎
Quality 75.95% 75.51% -0.44% 👎
Other metrics Before After Change
Lines 171 175 4
Changed files Quality Before Quality After Quality Change
src/darker/black_diff.py 75.95% ⭐ 75.51% ⭐ -0.44% 👎

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

File Function Complexity Length Working Memory Quality Recommendation

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


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!

Help us improve this quality report!

@flying-sheep
Copy link
Collaborator Author

Is this just a matter of taste or do you see pros and cons in each approach?

I think the approach here is simpler in two ways:

  1. it uses less code
  2. it checks directly for the difference that has to be handled as opposed to taking an indirect route over the version

but ultimately it’s a matter of taste as both solutions are likely to be robust.

Copy link
Owner

@akaihola akaihola left a comment

Choose a reason for hiding this comment

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

Thanks @flying-sheep for the improved solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging this pull request may close these issues.

2 participants