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

Try using setup.cfg declarative metadata #403

Merged
merged 15 commits into from
Oct 31, 2020
Merged

Try using setup.cfg declarative metadata #403

merged 15 commits into from
Oct 31, 2020

Conversation

MarcoGorelli
Copy link
Collaborator

@MarcoGorelli MarcoGorelli commented Oct 30, 2020

Trying to imitate asottile https://github.com/asottile/pyupgrade

Seems I'd put loads of extra things (taken from some cookiecutter template) which might not have been needed?

@s-weigand as mentioned on gitter, I think you should be included as co-author - if you agree I'll do so

@girip11 if I've done this correctly, it lets us have the default configs as a separate file

@MarcoGorelli MarcoGorelli marked this pull request as draft October 30, 2020 21:49
@MarcoGorelli MarcoGorelli marked this pull request as ready for review October 30, 2020 21:53
@codecov-io
Copy link

codecov-io commented Oct 31, 2020

Codecov Report

Merging #403 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #403   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           11        11           
  Lines          505       507    +2     
=========================================
+ Hits           505       507    +2     
Impacted Files Coverage Δ
nbqa/config.py 100.00% <100.00%> (ø)

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 e07baad...611a875. Read the comment docs.

setup.cfg Outdated Show resolved Hide resolved
@s-weigand
Copy link
Contributor

s-weigand commented Oct 31, 2020

Problems with bump2version and setup.cfg

bump2version sadly doesn't support the setup.cfg only layout properly (see c4urself/bump2version#83 and c4urself/bump2version#87).
The other issue with bump2version would be that it most likely will have a fight with setup-cfg-fmt and pre-commit-hooks/trailing-whitespace, since it adds trailing whitespaces (see c4urself/bump2version#161) and also rewrites the whole setup.cfg in config parser style (space indent -> tab indent).

I guess the only workaround to still use bump2version would be to use .bumpversion.cfg file.

Proposed setup.cfg changes

Version

The version can be read automagically if we set setuptools>=46.4.0 (released: May 17, 2020) as a requirement (see the packaging guide)

[metadata]
version = attr: package.__version__

Project Urls

Having links to the docs and issues on PyPi is a nice to have (should look something like this)

[metadata]
project_urls =
        Documentation = https://nbQA.readthedocs.io/en/latest/
        Source = https://github.com/nbQA-dev/nbQA
        Tracker = https://github.com/nbQA-dev/nbQA/issues

It renders like this on PyPi
grafik

Additional classifiers and keywords

I would also add the following classifiers (full list here)

[metadata]
classifiers =
    Framework :: Jupyter
    Operating System :: OS Independent
    Environment :: Console
    Topic :: Software Development :: Quality Assurance

keywords

[metadata]
keywords = jupyter, notebook, format, lint, ...

setup.cfg Outdated Show resolved Hide resolved
@sourcery-ai
Copy link

sourcery-ai bot commented Oct 31, 2020

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 1.78 ⭐ 2.21 ⭐ 0.43 👎
Method Length 46.30 ⭐ 47.93 ⭐ 1.63 👎
Working memory 7.84 🙂 7.75 🙂 -0.09 👍
Quality 81.51% 80.38% -1.13% 👎
Other metrics Before After Change
Lines 918 763 -155
Changed files Quality Before Quality After Quality Change
setup.py 53.75% 🙂 100.00% ⭐ 46.25% 👍
nbqa/main.py 79.19% ⭐ 79.19% ⭐ 0.00%
nbqa/config_parser.py 79.39% ⭐ 79.39% ⭐ 0.00%
nbqa/toml_parser.py 84.92% ⭐ 84.92% ⭐ 0.00%

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

File Function Complexity Length Working Memory Quality Recommendation
nbqa/main.py _run_on_one_root_dir 12 🙂 198 😞 19 ⛔ 35.44% 😞 Try splitting into smaller methods. Extract out complex expressions
nbqa/main.py _run_command 0 109 🙂 15 😞 59.92% 🙂 Extract out complex expressions
nbqa/main.py _map_python_line_to_nb_lines 1 ⭐ 79 🙂 10 😞 71.00% 🙂 Extract out complex expressions
nbqa/main.py _replace_temp_python_file_references_in_out_err 1 ⭐ 52 ⭐ 10 😞 75.17% ⭐ Extract out complex expressions
nbqa/main.py _get_command_not_found_msg 0 37 ⭐ 11 😞 76.70% ⭐ Extract out complex expressions

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!

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

@MarcoGorelli
Copy link
Collaborator Author

Thanks for your suggestions!

It's not too much effort to change version numbers, and there's usually some small changes that need to be done anyway, so I don't mind that not being automated just yet

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.

4 participants