Skip to content

Configure flake8. Fix flake8 errors where possible. #283

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

Closed
wants to merge 7 commits into from
Closed

Configure flake8. Fix flake8 errors where possible. #283

wants to merge 7 commits into from

Conversation

jgspiro
Copy link

@jgspiro jgspiro commented Mar 27, 2019

Fixed most flake8 warnings and errors in control package. Used autopep8 tool to fix most whitespace related errors. Test files are not done at the moment.

Some other fixed issues :

  • missing import for warn() statement
  • fixed some documentation (missing parameter docstring, ...)

Currently ignored flake8 warnings are : E402 (import not at top of file) and W605 (invalid escape sequence)

When reviewing the pull request, hiding whitespace changes will make it a lot easier to review all changes.

@jgspiro jgspiro marked this pull request as ready for review March 27, 2019 11:59
@jgspiro
Copy link
Author

jgspiro commented Mar 27, 2019

As planned, the Travis checks are failing, because I added a flake8 run to the travis configuration.
These are the errors/warings that are left, where it would be good to have some input about what to do with them :

control/lti.py:173:30: E721 do not compare types, use 'isinstance()'
control/modelsimp.py:413:5: F841 local variable 'Ymat' is assigned to but never used
control/frdata.py:371:13: E722 do not use bare 'except'
control/frdata.py:480:5: E722 do not use bare 'except'
control/freqplot.py:601:9: E722 do not use bare 'except'```

@moorepants
Copy link

control/lti.py:173:30: E721 do not compare types, use 'isinstance()'

Using isintance(thing, str) is fine for type checking. The if type(thing) == str above these lines is not a good idiom.

https://stackoverflow.com/questions/152580/whats-the-canonical-way-to-check-for-type-in-python

control/modelsimp.py:413:5: F841 local variable 'Ymat' is assigned to but never used

Remove it.

control/frdata.py:371:13: E722 do not use bare 'except'
control/frdata.py:480:5: E722 do not use bare 'except'
control/freqplot.py:601:9: E722 do not use bare 'except

Add specific exceptions.

@moorepants
Copy link

You also did not follow my suggestion to submit 1 PR per py file (or per sub-package at max).

@jgspiro
Copy link
Author

jgspiro commented Mar 27, 2019

You also did not follow my suggestion to submit 1 PR per py file (or per sub-package at max).

Since there is only 1 subpackage, I followed that suggestion. I didn't think fixing 25+ individual files and creating pull requests for all of them would be easier to manage. The person reviewing could always review one file at a time.

@jgspiro
Copy link
Author

jgspiro commented Mar 27, 2019

control/lti.py:173:30: E721 do not compare types, use 'isinstance()'

Using isintance(thing, str) is fine for type checking. The if type(thing) == str above these lines is not a good idiom.

https://stackoverflow.com/questions/152580/whats-the-canonical-way-to-check-for-type-in-python

control/modelsimp.py:413:5: F841 local variable 'Ymat' is assigned to but never used

Remove it.

control/frdata.py:371:13: E722 do not use bare 'except'
control/frdata.py:480:5: E722 do not use bare 'except'
control/freqplot.py:601:9: E722 do not use bare 'except

Add specific exceptions.

Right. I understand what the errors mean. The point was to get suggestions by someone who wrote the code (or, has more commits, or wants to review) before I change it to something else.

@moorepants
Copy link

I offered my time and suggestions and you clearly don't respect that from your response. I have nothing more to offer.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 78.328% when pulling 3832700 on jgspiro:feature/flake8 into e4e7a0d on python-control:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 78.328% when pulling 3832700 on jgspiro:feature/flake8 into e4e7a0d on python-control:master.

@coveralls
Copy link

coveralls commented Mar 27, 2019

Coverage Status

Coverage decreased (-0.05%) to 78.328% when pulling 13468a9 on jgspiro:feature/flake8 into e4e7a0d on python-control:master.

@repagh
Copy link
Member

repagh commented Mar 27, 2019

Would it be better to just configure & run flake8 with the --exit-zero flag? Then the checks won't fail due to flake8, and we can slowly, unit-by-unit, fix the formatting and code.

I don't feel happy either with over 30 changed files in one PR and I would not like this to get hurried through.

@ilayn
Copy link

ilayn commented Mar 27, 2019

This has to be done in a separate Travis CI job to make sure that later no new PEP8 problems creep in. Over SciPy, we created a very fast job that runs pycodestyle and pyflakes that checks specifically this and a few other cosmetics. Then you just need to see the green checkmark and not review everything.

@jgspiro jgspiro closed this Mar 29, 2019
@jgspiro jgspiro deleted the feature/flake8 branch March 29, 2019 08:38
@murrayrm murrayrm mentioned this pull request Jun 11, 2019
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.

5 participants