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

Flake8 linting of core modules (rtree/index.py and rtree/core.py, ignoring E501) #136

Merged
merged 12 commits into from
Dec 21, 2019

Conversation

sr-murthy
Copy link
Collaborator

Flake8 linting of core modules (rtree/index.py and rtree/core.py, ignoring E501)

…) and ignore F821 (undefined name error) for conditional naming of `xrange` and `basestring` for Py2 case
@hobu
Copy link
Member

hobu commented Dec 20, 2019

Add the linter to the CI testing?

@sr-murthy
Copy link
Collaborator Author

sr-murthy commented Dec 20, 2019

This would be fine, except that if you were using Python >= 3 the linting command produces two undefined name errors in rtree/index.py

$ flake8 --ignore=E501 rtree/index.py 
rtree/index.py:15:13: F821 undefined name 'xrange'
rtree/index.py:16:20: F821 undefined name 'basestring'

These two errors are a result of the conditional re-naming of xrange and basestring if the Python version is 2 starting here

https://github.com/Toblerity/rtree/blob/master/rtree/index.py#L14

This is perfectly fine functionally, but obviously it does generate the F821 errors if using Python >= 3. It should not generate those errors if using Py2. To make the linting step work for both Py2 and Py3 you could obviously wrap the original command in an appropriate conditional shell statement

@hobu
Copy link
Member

hobu commented Dec 20, 2019

These two errors are a result of the conditional re-naming of xrange and basestring if the Python version is 2 starting here

That's yuck. We can probably ditch the Python 2 support anyway. Please make another PR that tosses that.

@sr-murthy
Copy link
Collaborator Author

You would not want to exclude F821 entirely because it is useful to catch this generally.

@sr-murthy
Copy link
Collaborator Author

OK, no problem.

@sr-murthy
Copy link
Collaborator Author

I rebased this branch against the Py2 branch, and updated the CI scripts to include a step to pip install Flake8 and run it, before running the tests. It seems to be fine.

@sr-murthy
Copy link
Collaborator Author

It may be better to create a separate step inside the CI scripts for Flake8 linting - ATM it is a substep inside the pytest step.

@hobu hobu added this to the 1.0.0 milestone Dec 21, 2019
@sr-murthy sr-murthy merged commit d202812 into Toblerity:master Dec 21, 2019
@sr-murthy sr-murthy deleted the flake8-linting branch December 21, 2019 15:30
@hobu hobu modified the milestones: 1.0.0, 0.9.4 Feb 11, 2020
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.

2 participants