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

Upgrade versioneer, fix flake8 + other misc fixes #1336

Merged
merged 3 commits into from
Sep 27, 2021

Conversation

DimitriPapadopoulos
Copy link
Contributor

https://lgtm.com/projects/g/bids-standard/bids-validator/?severity=error

Fix the first of two errors, the fix seems rather obvious.

The other error is in _version.py and has been fixed upstream in python-versioneer/python-versioneer#250.

@codecov
Copy link

codecov bot commented Sep 14, 2021

Codecov Report

Merging #1336 (9b5ebe3) into master (7cc3947) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1336   +/-   ##
=======================================
  Coverage   84.78%   84.78%           
=======================================
  Files          82       82           
  Lines        3372     3372           
  Branches      999      999           
=======================================
  Hits         2859     2859           
  Misses        434      434           
  Partials       79       79           

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 7cc3947...9b5ebe3. Read the comment docs.

Copy link
Member

@sappelhoff sappelhoff left a comment

Choose a reason for hiding this comment

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

for the _version related problem, we could update our vendored versioneer version: https://github.com/python-versioneer/python-versioneer#updating-versioneer

That should fix it, be backward compatible, and give us an up to date versioneer that is now being maintained by our very own @effigies

@DimitriPapadopoulos
Copy link
Contributor Author

CI fails with:

bids-validator/bids_validator/_version.py:339:80: E501 line too long (84 > 79 characters)

I don't want to modify the _version.py file generated by versioneer, I cannot find a versioneer option to obtain a different _version.py file. The only option I can think of is to change the CI configuration to accept lines < 85 characters instead of lines < 80 characters. Or perhaps < 89 characters like black?

Copy link
Member

@sappelhoff sappelhoff 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 setup a section on flake8 in our setup.cfg to ignore the versioneer files.

Example how to do it

Place where to do it here

@DimitriPapadopoulos
Copy link
Contributor Author

Should be OK for flake8.

Not sure how to fix that for pytest:

setup.cfg files are general purpose configuration files, used originally by distutils, and can also be used to hold pytest configuration if they have a [tool:pytest] section.
[...]

Warning:

Usage of setup.cfg is not recommended unless for very simple use cases. .cfg files use a different parser than pytest.ini and tox.ini which might cause hard to track down problems. When possible, it is recommended to use the latter files, or pyproject.toml, to hold your pytest configuration.

Is it OK to create a pytest.ini file?

@DimitriPapadopoulos
Copy link
Contributor Author

Actually not OK for flake8, because as far as I can see, it is run from bids-validator, not from bids-validator/bids-validator.

@sappelhoff
Copy link
Member

Is it OK to create a pytest.ini file?

if you can figure out a minimal solution that involves us having to add a file, that'd still be fine I think.

But reusing existing config files would be better :) (if possible)

@effigies
Copy link
Collaborator

Pytest can be configured in setup.cfg.

@DimitriPapadopoulos
Copy link
Contributor Author

I know, but the pytest documentation warns:

Warning:

Usage of setup.cfg is not recommended unless for very simple use cases. .cfg files use a different parser than pytest.ini and tox.ini which might cause hard to track down problems. When possible, it is recommended to use the latter files, or pyproject.toml, to hold your pytest configuration.

Hopefully this is a very simple case 😃

@DimitriPapadopoulos
Copy link
Contributor Author

DimitriPapadopoulos commented Sep 17, 2021

OK, all options have been added to setup.cfg.

Now I need to tell Code Climate not to bother with versioneer.py and _version.py.

@DimitriPapadopoulos
Copy link
Contributor Author

See #1341 for shutting up Cold Climate. Hopefully it'll work...

@DimitriPapadopoulos
Copy link
Contributor Author

Still these codeclimate errors. I just don't know how to exclude the versioneer files. Any clues?

The ci/circleci: test_docker failure looks like a more general problem, unrelated to this PR.

@sappelhoff
Copy link
Member

I think code climate only complains on new changes. So after committing the versioneer files initially, it won't be a problem in the next prs.

It's not as satisfying, but I don't know how else to fix it.

@DimitriPapadopoulos
Copy link
Contributor Author

DimitriPapadopoulos commented Sep 18, 2021

I thought #1341 would help:

exclude_patterns:
  - "**/versioneer.py"
  - "**/_version.py"

It should according to the documentation, but doesn't :-(

@sappelhoff
Copy link
Member

sappelhoff commented Sep 27, 2021

In 754bf25 I tried whether the exclude patterns work when they are absolute (relative to the .codeclimate.yml file), instead of globs. That didn't work.

Now I am wondering whether .codeclimate.yml is perhaps ignored in general, and should be at the root of the REPO, not nested inside the bids-validator directory 🤔

@DimitriPapadopoulos
Copy link
Contributor Author

Now I am wondering whether .codeclimate.yml is perhaps ignored in general, and should be at the root of the REPO, not nested inside the bids-validator directory thinking

Makes sense. I'm moving it around in #1347.

This property is overwritten by another property in the same object literal.

While I haven't looked much into the code, the fix looks obvious.
Fix LGTM.com error: Suspicious unused loop iteration variable
For loop variable 'i' is not used in the loop body.
@DimitriPapadopoulos
Copy link
Contributor Author

DimitriPapadopoulos commented Sep 27, 2021

Eventually got CodeClimate to work properly by (I think) moving bids-validator/.codeclimate.yml to .codeclimate.yml (#1347).

Copy link
Member

@sappelhoff sappelhoff left a comment

Choose a reason for hiding this comment

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

wonderful, thanks for sticking with this.

@sappelhoff sappelhoff changed the title Fix LGTM.com errors Upgrade versioneer, fix flake8 + other misc fixes Sep 27, 2021
@sappelhoff sappelhoff merged commit 399f57c into bids-standard:master Sep 27, 2021
@DimitriPapadopoulos DimitriPapadopoulos deleted the lgtm_errors branch September 27, 2021 19:59
rob-luke pushed a commit to rob-luke/bids-validator that referenced this pull request Jan 31, 2022
* Fix LGTM.com error: Overwritten property

This property is overwritten by another property in the same object literal.

While I haven't looked much into the code, the fix looks obvious.

* Update versioneer: 0.18 → 0.20

Fix LGTM.com error: Suspicious unused loop iteration variable
For loop variable 'i' is not used in the loop body.

* New attempt to please CodeClimate

Try to mimic examples from:
https://docs.codeclimate.com/docs/default-analysis-configuration
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.

3 participants