-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from cribbslab/AC-py13
updated github actions so py3.10+ tested
- Loading branch information
Showing
4 changed files
with
56 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,50 @@ | ||
'''test_style | ||
============= | ||
Purpose | ||
------- | ||
Runs pep8 style tests - could be removed if you dont want to | ||
conform to pep8 for this project? | ||
This script is best run within nosetests:: | ||
nosetests tests/test_style.py | ||
''' | ||
import pep8 | ||
import pycodestyle | ||
import glob | ||
import os | ||
from nose.tools import ok_ | ||
|
||
# DIRECTORIES to examine | ||
EXPRESSIONS = ( | ||
('FirstLevel', 'scpipelines/*.py'), | ||
('SecondLevel', 'scpipelines/version.py')) | ||
|
||
# Codes to ignore in the pep8 BaseReport | ||
IGNORE = set(('E101', # indentation contains mixed spaces and tabs | ||
'E201', # whitespace after '(' | ||
'E202', # whitespace before ')' | ||
'E122', # continuation line missing indentation or outdented | ||
'E265', # block comment should start with '# ' | ||
'E501', # line too long (82 > 79 characters) | ||
'E502', # the backslash is redundant between brackets | ||
'E731', # do not assign a lambda expression, use a def | ||
'W191', | ||
'W291', | ||
'W293', | ||
'W391', | ||
'W503', # line break before binary operator | ||
'W601', | ||
'W602', | ||
'files', | ||
'directories', | ||
'physical lines', | ||
'logical lines',)) | ||
# Codes to ignore in the pycodestyle BaseReport | ||
IGNORE = { | ||
'E101', # indentation contains mixed spaces and tabs | ||
'E201', # whitespace after '(' | ||
'E202', # whitespace before ')' | ||
'E122', # continuation line missing indentation or outdented | ||
'E265', # block comment should start with '# ' | ||
'E501', # line too long (82 > 79 characters) | ||
'E502', # the backslash is redundant between brackets | ||
'E731', # do not assign a lambda expression, use a def | ||
'W191', | ||
'W291', | ||
'W293', | ||
'W391', | ||
'W503', # line break before binary operator | ||
'W601', | ||
'W602' | ||
} | ||
|
||
|
||
def check_style(filename): | ||
'''check style of filename. | ||
''' | ||
'''check style of filename.''' | ||
|
||
p = pep8.StyleGuide(quiet=True) | ||
report = p.check_files([filename]) | ||
style_guide = pycodestyle.StyleGuide(quiet=True, ignore=IGNORE) | ||
report = style_guide.check_files([filename]) | ||
|
||
# count errors/warning excluding | ||
# those to ignore | ||
take = [y for x, y | ||
in list(report.counters.items()) if x not in IGNORE] | ||
found = ['%s:%i' % (x, y) for x, y | ||
in list(report.counters.items()) if x not in IGNORE] | ||
total = sum(take) | ||
ok_(total == 0, | ||
'pep8 style violations: %s' % ','.join(found)) | ||
# count errors/warnings excluding those to ignore | ||
assert report.total_errors == 0, f"Style violations in {filename}" | ||
|
||
|
||
def test_style(): | ||
'''test style of scripts | ||
''' | ||
'''test style of scripts''' | ||
|
||
for label, expression in EXPRESSIONS: | ||
|
||
files = glob.glob(expression) | ||
files.sort() | ||
|
||
for f in files: | ||
if os.path.isdir(f): | ||
continue | ||
check_style.description = os.path.abspath(f) | ||
yield(check_style, os.path.abspath(f)) | ||
yield check_style, os.path.abspath(f) |