#763 clean all unused `import` and reorder imports
Merged by tkopecek. Opened by julian8628.
julian8628/koji clean-import  into  master

Download 763.patch

a follow-up of PR #762 to clean up all unnecessary import
and reorder imports by PEP8

Flake8 is introduced here to validate the format(currently only for imports)

following modules are required here

pip install flake8
pip install flake8-import-order

to check format by flake8:

flake8 or make flake8

BTW, currently, unittests code are skipped.

fixes: #1537

Current function of module requires cgi, so I would remove it from nested imports and leave on global level.

I would leave those explicit import for clarity (cli/koji except 'types') as they are directly used here. What would I rather like to see there (in future) is removal of import * from koji_cli.commands. It would be nice to somehow detect only command handlers (probably creating some import function handling functions in similar way as plugins)

If we're going to clean up the import here, might want to fix the ordering to follow pep8

6 new commits added

  • leave some unused imports to clarify the usage
  • update flake8 config
  • flake8: noqa comments
  • reorder imports by isort
  • add flake8 and flake8-isort and flake8-import-order plugins supporting
  • remove unused import in plugins/hub/rpm2maven.py

rebased onto a86176023c52106de4bf9bb9addfc6b4e2ac4774

If we're going to clean up the import here, might want to fix the ordering to follow pep8

I added a simple check by flake8. Do you have any suggestions to improve flake8 config?

@tkopecek
updated. Please review again

You can now drop other import cgi throughout the file.

If you leave import logging in top of file, these error messages needn't to be bypassed, not?

add OptionParser?

...and greetings

from . import context ?

urlgabber is not used anywhere AFAIK

@tkopecek Updated

1 new commit added

  • more adjustings for imports

:thumbsup:

Fedora has isort, but not flake8-isort. I'd rather not require folks to pip install anything.

This flake8 config does not seem to work for me. When I simply run flake8, it does not appear to check any files.

[mike@localhost koji]$ flake8 -v|&grep Checking
flake8.checker            MainProcess     80 INFO     Checking 0 files

rebased onto 8e4585306b6ab36ba1f12c311cbb7634c0d8b01c

Fedora has isort, but not flake8-isort. I'd rather not require folks to pip install anything.

Sorry for my mistake. flake8-isort is not required here

This flake8 config does not seem to work for me. When I simply run flake8, it does not appear to check any files.
[mike@localhost koji]$ flake8 -v|&grep Checking
flake8.checker MainProcess 80 INFO Checking 0 files

it works for me. here are my flake8 version and installed plugins

$ flake8 --version
3.5.0 (import-order: 0.16, mccabe: 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.6.0) CPython 3.5.3 on Linux

rebased onto 54f7e8f982208815d008c6c23a67e8da81f56603

rebased onto 8e4585306b6ab36ba1f12c311cbb7634c0d8b01c

Issue #1537

@julian8628 - does it make sense to rebase this one?

rebased onto 84b6aa4ac2a8cf751633b5ce7fa94ac839eb86cf

@tkopecek updated

@mikem could you please check if .flake8 works for you now?

rebased onto 8df617e4f4b037d713358bf12782f3aa3b7bd388

Config works for me.

:thumbsup:

Sorry, it needs another rebase (tests are failing due to broken merge).

rebased onto a00df18546b30146135c76659d4c57a3879fb86b

rebased

Commit 3c4377e8 fixes this pull-request

Pull-Request has been merged by tkopecek

Metadata Update from @julian8628:
- Pull-request tagged with: no_qe

Metadata