Feature #2355

make codebase compliant with pep8

Added by Zach Welch over 2 years ago. Updated over 2 years ago.

Status:Resolved Start date:02/24/2015
Priority:Normal Due date:
Assignee:Zach Welch % Done:

100%

Category:-
Target version:0.5.0
Chirp Version:daily Model affected:(All models)

Description

Since we want good Python style to be used, we should enforce it with the pep8 tool.

The first order of business will be to fix the whitespace problem. This single issue represents the vast majority of reported problems. Once this noise is eliminated, additional problems can be isolated and fixed. Per discussion with Dan S., we will move the code toward 4 space indentation levels (no tabs), proper spacing at top of scopes, line lengths < 80 characters, and so on. Some details will be worked out once patching is underway. Additional style conventions will be listed in this issue as this process moves forward.

The final goals of this issue are twofold. First, a firm style guide will be developed in the form of a specific configuration for the pep8 tool. Second, the pep8 tool will be added to the automated patch testing process, preventing further style issues from ever reaching the main repository.


Related issues

related to Bug #2389: Cannot edit cells in all columns Closed 03/04/2015

Associated revisions

Revision 2387:9783803e40b5
Added by Zach Welch over 2 years ago

Add pep8 checker script (#2355)

This patch adds a new script that runs the pep8 tool on the CHIRP source
code files. This script is intended to be included in the repository
pre-commit hook, preventing patches from causing style regressions.

The script checks a blacklist of files that are not yet compliant with
the style standards, and those files will not be scanned (unless -a is
given). Since no new files should ever be added to the blacklist, it
should eventually shrink to empty, and the script will check the entire
codebase.

The blacklist makes it safe to begin using this tool immediately, so
this patch also adds a call to it from run_all_tests.sh.

Revision 2388:afae3a7ecca6
Added by Zach Welch over 2 years ago

Fix style issues (1/4) (#2355)

This patch contains whitespace-only changes that eliminate all of the
PEP8 style warnings in the CLI and GUI scripts.

Revision 2389:3f4049aaf3ef
Added by Zach Welch over 2 years ago

Fix style issues (2/4) (#2355)

This patch fixes the style in a handful of files and removes them
from pep8.blacklist.

Revision 2390:f129e0344ad8
Added by Zach Welch over 2 years ago

Fix style issues (3/4) (#2355)

This patch fixes more low-hanging style issues. For the most part,
these are all whitespace changes, but there were a handful of idiomatic
changes flagged by the pep8 tool too: "x.has_key(y)" is now "y in x".

Revision 2391:5293adb57b9b
Added by Zach Welch over 2 years ago

Fix style issues (4/4) (#2355)

More low-hanging style issues.

Revision 2392:fe8d6ca4e514
Added by Zach Welch over 2 years ago

Fix style issues in setup.py (#2355)

This patch brings setup.py into conformance with PEP8 rules and removes
it from the blacklist. It also rewrites the staticify_chirp_module
routine to be more idiomatic.

Revision 2394:530189687101
Added by Dan Smith over 2 years ago

Run pep8 in a virtualenv with a pep8==1.4.6

This makes our test runner generate a virtualenv, install pep8==1.4.6
inside, and run our pep8 test using it.

Fallout from issue #2355

Revision 2395:97fdd231f05b
Added by Zach Welch over 2 years ago

Improve cpep8.py (#2355)

This patch expands cpep8.manifest to contain all files, allowing the
cpep8.py script to use it instead of scanning for files. Scanning can
now be done with --scan. If both --scan and --update options are given,
the manifest file will be updated with the scan results.

Altogether, this should fix problems that Windows users were seeing,
caused by mismatches between the dynamic manifest and the blacklist
(due to different path separators).

Revision 2396:78c4297e6a89
Added by Zach Welch over 2 years ago

Add cpep8.sh wrapper script (#2355)

This patch moves the virtualenv setup out of run_all_tests.sh, allowing
cpep8.py to be run on its own with the correct module versions. This
patch also moves the virtualenv temporary directory into tools/ and
adds it to the .hgignore file.

Revision 2397:9deae1ac816a
Added by Zach Welch over 2 years ago

Update cpep8 to use pep8 1.6.2 (#2355)

This patch updates the virtualenv version of pep8 to 1.6.2, chasing
down the new style errors that pop up in the already cleaned files.

Revision 2425:f70627fae1f4
Added by Filippi Marco over 2 years ago

Fix style issues in ft817.py

This patch brings ft817.py into conformance with PEP8 rules and removes
it from the blacklist.

improves #2355

Revision 2426:f2a347ba53fd
Added by Filippi Marco over 2 years ago

Fix style issues in ft857.py

This patch brings ft857.py into conformance with PEP8 rules and removes
it from the blacklist.

improves #2355

Revision 2427:c377004a0580
Added by Filippi Marco over 2 years ago

Fix style issues in ft1d.py

This patch brings ft1d.py into conformance with PEP8 rules and removes
it from the blacklist.

improves #2355

Revision 2398:50d4a0d71fde
Added by Zach Welch over 2 years ago

Fix bad lambda conversion in platform.py (#2355)

... and today I learned that python's lambda expressions have an
implicit "return" statement, while defs don't.

Revision 2399:ac94be089348
Added by Zach Welch over 2 years ago

Allow cpep8.py script to make exceptions (#2355)

This patch enhances the cpep8.py script with the ability to ignore a
list of style rules on per-file basis. There are cases where it may be
too disruptive to eliminate all style issues, so this mechanism allows
the style checker to enforce the remainder of the style rules. The new
--strict option will cause the script to ignore the exception list.

As a bonus, this change improves interactivity, so --verbose will cause
the name of the file to be printed as it is checked (rather than
printing one long list before it started). The downside: the pep8
module catches KeyboardInterrpt, so it's hard impossible to stop once it
gets started.

Revision 2400:92f564f71d3e
Added by Zach Welch over 2 years ago

Fix style issues in run_tests (#2355)

The run_tests script contains logic to set the path for importing the
chirp modules. This violates the style rule that all module-level
imports must be at the top of the file, so I added it as an exception
for this file.

Revision 2401:e452b57af245
Added by Zach Welch over 2 years ago

Fix style issues in unit tests (#2355)

The memedit unit tests needed an exception, as that module uses a lambda
to fake localization when importing the UI module.

Revision 2402:e9ff56ef6e99
Added by Zach Welch over 2 years ago

Fix style issues in csvdump scripts (#2355)

Revision 2403:54506f9381ba
Added by Zach Welch over 2 years ago

Fix style issues in make_supported.py (#2355)

Like run_tests, this script monkeys with the path to find the chirp
modules, so it gets a similar exception.

Revision 2404:114f67538e10
Added by Zach Welch over 2 years ago

Fix style issues in chirp_common.py (#2355)

Revision 2405:70a1360291cd
Added by Zach Welch over 2 years ago

Fix style issues in elib_intl.py (#2355)

Revision 2406:cc5e631f4364
Added by Zach Welch over 2 years ago

Fix style issues in pyPEG.py (#2355)

Revision 2407:d2d940f00b46
Added by Zach Welch over 2 years ago

Fix style issues in bandplans (#2355)

Revision 2408:2d073e4f68b7
Added by Zach Welch over 2 years ago

Fix style issues in chirp module (#2355)

Revision 2409:3a7c3cb15f7a
Added by Zach Welch over 2 years ago

Fix style issues in bitwise.py (#2355)

Revision 2410:a776caed41f5
Added by Zach Welch over 2 years ago

Fix style issues in settings.py (#2355)

Revision 2411:f0b4360fc6f4
Added by Zach Welch over 2 years ago

Fix style issues in common.py (#2355)

Revision 2412:d0d9c3a454ed
Added by Zach Welch over 2 years ago

Fix style issues in editorset.py (#2355)

Revision 2413:9fc417458811
Added by Zach Welch over 2 years ago

Fix style issues in importdialog.py (#2355)

Revision 2414:a536119f2252
Added by Zach Welch over 2 years ago

Fix style issues in mainapp.py (#2355)

Revision 2415:1c141c2afbc9
Added by Zach Welch over 2 years ago

Fix style issues in memdetail.py (#2355)

Revision 2416:d6b8c257d115
Added by Zach Welch over 2 years ago

Fix style issues in memedit.py (#2355)

Revision 2417:816a3bfa0f17
Added by Zach Welch over 2 years ago

Fix style issues in miscwidgits.py (#2355)

Revision 2418:275779730181
Added by Zach Welch over 2 years ago

Fix style issues in reporting.py (#2355)

Revision 2419:d4d88dc3ceb8
Added by Zach Welch over 2 years ago

Fix style issues in fips.py (#2355)

Revision 2420:aa9c3995e213
Added by Zach Welch over 2 years ago

Fix style issues in tools (#2355)

Revision 2430:239cc94f7cc7
Added by Zach Welch over 2 years ago

Fix style issues in some drivers (#2355)

Revision 2431:a83a4b12fc9a
Added by Zach Welch over 2 years ago

Fix style issues in ap510.py (#2355)

Revision 2432:a961f709190a
Added by Zach Welch over 2 years ago

Fix style issues in baofeng_uv3r.py (#2355)

Revision 2433:50faf4feafae
Added by Zach Welch over 2 years ago

Fix style issues in bjuv55.py (#2355)

Revision 2434:d7ba9ac3760b
Added by Zach Welch over 2 years ago

Fix style issues in yaesu_clone.py (#2355)

Revision 2435:86ab6a9d2741
Added by Zach Welch over 2 years ago

Fix style issues in wouxum_common.py (#2355)

Revision 2436:bec0f83df2e5
Added by Zach Welch over 2 years ago

Fix style issues in wouxum.py (#2355)

Revision 2437:cb7f74df486a
Added by Zach Welch over 2 years ago

Fix style issues in vxa700.py (#2355)

Revision 2438:d4f317504a64
Added by Zach Welch over 2 years ago

Fix style issues in uv5r.py (#2355)

Revision 2439:b4c37158c569
Added by Zach Welch over 2 years ago

Fix style issues in uvb5.py (#2355)

Revision 2440:7e1eaa7ff715
Added by Zach Welch over 2 years ago

Fix style issues in rfinder.py (#2355)

Revision 2441:e0f102d5d0c4
Added by Zach Welch over 2 years ago

Fix style issues in idrp.py (#2355)

Revision 2442:a68c44c06ead
Added by Zach Welch over 2 years ago

Fix style issues in puxing.py (#2355)

Revision 2443:4b14c8743dd7
Added by Zach Welch over 2 years ago

Fix style issues in leixen.py (#2355)

Revision 2444:8f9f90e0a372
Added by Zach Welch over 2 years ago

Fix style issues in kyd.py (#2355)

Revision 2445:6d4441dca3d0
Added by Zach Welch over 2 years ago

Fix style issues in h777.py (#2355)

Revision 2446:e3dfb468c230
Added by Zach Welch over 2 years ago

Fix style issues in kenwood_hmk.py (#2355)

Revision 2447:252537952ad4
Added by Zach Welch over 2 years ago

Fix style issues in kguv8d.py (#2355)

Revision 2448:248895059805
Added by Zach Welch over 2 years ago

Fix style issues in id31.py (#2355)

Revision 2449:7bf341df60d4
Added by Zach Welch over 2 years ago

Fix style issues in id800.py (#2355)

Revision 2450:a98c9e0b3c83
Added by Zach Welch over 2 years ago

Fix style issues in icomciv.py (#2355)

Revision 2451:79e3eb6d6439
Added by Zach Welch over 2 years ago

Fix style issues in tk8102.py (#2355)

Revision 2452:4e4cecae1633
Added by Zach Welch over 2 years ago

Fix style issues in thuv1f.py (#2355)

Revision 2453:288468fc1405
Added by Zach Welch over 2 years ago

Fix style issues in thd72.py (#2355)

Revision 2456:abfee7ba681b
Added by Zach Welch over 2 years ago

Fix style issues in some drivers (#2355)

Revision 2457:69ed07f13f14
Added by Zach Welch over 2 years ago

Fix style issues in ft50_ll.py (#2355)

Revision 2458:77db330dd715
Added by Zach Welch over 2 years ago

Fix style issues in ft60.py (#2355)

Revision 2459:f2093253d1ce
Added by Zach Welch over 2 years ago

Fix style issues in ft7800.py (#2355)

Revision 2460:2a340d2443ce
Added by Zach Welch over 2 years ago

Fix style issues in ft90.py (#2355)

Revision 2461:91603ce76689
Added by Zach Welch over 2 years ago

Fix style issues in ftm350.py (#2355)

Revision 2462:63998381c3af
Added by Zach Welch over 2 years ago

Fix style issues in vx170.py (#2355)

Revision 2463:8fbe7fa65c30
Added by Zach Welch over 2 years ago

Fix style issues in vx2.py (#2355)

Revision 2464:0ce82b660bef
Added by Zach Welch over 2 years ago

Fix style issues in vx3.py (#2355)

Revision 2465:02c63a9c9723
Added by Zach Welch over 2 years ago

Fix style issues in vx5.py (#2355)

Revision 2466:53df900f3cc5
Added by Zach Welch over 2 years ago

Fix style issues in vx510.py (#2355)

Revision 2467:62580e89d5d6
Added by Zach Welch over 2 years ago

Fix style issues in vx6.py (#2355)

Revision 2468:6c9bfcd24fc1
Added by Zach Welch over 2 years ago

Fix style issues in vx7.py (#2355)

Revision 2469:240cbe2fd701
Added by Zach Welch over 2 years ago

Fix style issues in vx8.py (#2355)

Revision 2470:e326e2b0eb69
Added by Zach Welch over 2 years ago

Fix style issues in th9800.py (#2355)

Revision 2471:4cfbdccfe32a
Added by Zach Welch over 2 years ago

Fix style issues in th_uv3r.py (#2355)

Revision 2472:a0b3a6cc71ee
Added by Zach Welch over 2 years ago

Fix style issues in th_uv3r25.py (#2355)

Revision 2473:14debb2be8c3
Added by Zach Welch over 2 years ago

Fix style issues in th_uvf8d.py (#2355)

Revision 2474:1857a9cda2bd
Added by Zach Welch over 2 years ago

Fix style issues in tmv71*.py (#2355)

Revision 2475:2c533188a405
Added by Zach Welch over 2 years ago

Fix style issues in ic208.py (#2355)

Revision 2476:3387e1c46b3a
Added by Zach Welch over 2 years ago

Fix style issues in ic2100.py (#2355)

Revision 2477:8907ef164cfc
Added by Zach Welch over 2 years ago

Fix style issues in ic2200.py (#2355)

Revision 2478:f1ab9709b59d
Added by Zach Welch over 2 years ago

Fix style issues in ic2720.py (#2355)

Revision 2479:c3034c1907df
Added by Zach Welch over 2 years ago

Fix style issues in ic2820.py (#2355)

Revision 2480:f035597d6816
Added by Zach Welch over 2 years ago

Fix style issues in ic9x.py (#2355)

Revision 2481:0b2944247431
Added by Zach Welch over 2 years ago

Fix style issues in ic9x_icf.py (#2355)

Revision 2482:ddd314976638
Added by Zach Welch over 2 years ago

Fix style issues in ic9x_icf_ll.py (#2355)

Revision 2483:de60eaa4f6f3
Added by Zach Welch over 2 years ago

Fix style issues in ic9x_ll.py (#2355)

Revision 2484:42ce3492955c
Added by Zach Welch over 2 years ago

Fix style issues in icf.py (#2355)

Revision 2485:b17c304408e7
Added by Zach Welch over 2 years ago

Fix style issues in icq7.py (#2355)

Revision 2486:9c026d709f0f
Added by Zach Welch over 2 years ago

Fix style issues in ict70.py (#2355)

Revision 2487:e58ab86ababe
Added by Zach Welch over 2 years ago

Fix style issues in ict8.py (#2355)

Revision 2488:a0b10f0172f3
Added by Zach Welch over 2 years ago

Fix style issues in icw32.py (#2355)

Revision 2489:3dd00b36e53d
Added by Zach Welch over 2 years ago

Fix style issues in icx8x.py (#2355)

Revision 2490:9fb095b968af
Added by Zach Welch over 2 years ago

Fix style issues in icx8x_ll.py (#2355)

Revision 2491:6915b55e7e9c
Added by Zach Welch over 2 years ago

Fix bug caused by style fix (#2355)

I introduced a minor typo during my cleanup. Thanks to Richard Cochran
for reporting the mistake.

Revision 2511:94b6ecd48c0f
Added by Zach Welch over 2 years ago

Improve cpep8 scripts (#2355)

This patch adds prints to cpep8.py's scanning function. It's useful to
know what files the script is scanning during an update, as the in-tree
virtualenv (or other files) may be included by accident.

This patch also fixes cpep8.sh to use the correct path to cpep8.py,
allowing it to be run from anywhere in the source tree.

History

Updated by Zach Welch over 2 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 60

Updated by Zach Welch over 2 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 60 to 100

This task has been accomplished. All of the CHIRP source code passes the pep8 tests, and the cpep8.py script is run as part of the run_all_tests.sh script.

The next step will be to make the source code compliant with pylint's stricter standards, but that is another feature entirely (#159).

Also available in: Atom PDF