Skip to content

Commit

Permalink
flake8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
natifridman committed Sep 19, 2023
1 parent d2e38b9 commit f3a8910
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/flake8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
python -m pip install --upgrade pip
pip install flake8
- name: Run Flake8
run: flake8 . --ignore=E266,E261,E265 --max-line-length=120 --count
run: flake8 . --ignore=E266,E261,E265,W503 --max-line-length=120 --count
4 changes: 2 additions & 2 deletions src/vse_sync_pp/analyzers/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def collect(self, *rows):
raise CollectionIsClosed()
self._rows += rows

def prepare(self, rows): # pylint: disable=no-self-use
def prepare(self, rows):
"""Return (columns, records) from collected data `rows`
`columns` is a sequence of column names
Expand Down Expand Up @@ -241,7 +241,7 @@ def prepare(self, rows):
def test(self, data):
if len(data) == 0:
return (False, "no data")
if frozenset(data.state.unique()).difference(self.locked): # pylint: disable=no-member
if frozenset(data.state.unique()).difference(self.locked):
return (False, "loss of lock")
terr_min = data.terror.min()
terr_max = data.terror.max()
Expand Down
6 changes: 3 additions & 3 deletions src/vse_sync_pp/parsers/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ def relative_timestamp(parsed, tzero):

class Parser():
"""A base class providing common parser functionality"""
def make_parsed(self, elems): # pylint: disable=no-self-use
def make_parsed(self, elems):
"""Return a namedtuple value from parsed iterable `elems`.
Raise :class:`ValueError` if a value cannot be formed from `elems`.
"""
raise ValueError(elems)

def parse_line(self, line): # pylint: disable=no-self-use,unused-argument
def parse_line(self, line):
"""Parse `line`.
If `line` is accepted, return a namedtuple value.
Expand All @@ -96,7 +96,7 @@ def parse(self, file, relative=False):
"""
tzero = None
for line in file:
parsed = self.parse_line(line) # pylint: disable=assignment-from-none
parsed = self.parse_line(line)
if parsed is not None:
if relative:
tzero, parsed = relative_timestamp(parsed, tzero)
Expand Down
24 changes: 11 additions & 13 deletions src/vse_sync_pp/parsers/phc2sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,17 @@ class TimeErrorParser(Parser):
@staticmethod
def build_regexp():
"""Return a regular expression string for parsing phc2sys log file lines"""
return r'\s'.join((
r'^phc2sys' + # noqa: W504
r'\[([1-9][0-9]*\.[0-9]{3})\]:' + # timestamp # noqa: W504
r'(?:\s\[ptp4l\.\d\..*\])?', # configuration file name
r'CLOCK_REALTIME phc offset\s*',
r'(-?[0-9]+)', # time error
r'(\S+)', # state
r'freq\s*',
r'([-+]?[0-9]+)', # frequency error
r'delay\s*',
r'(-?[0-9]+)' + # delay # noqa: W504
r'\s*.*$',
))
return r'\s'.join((r'^phc2sys'
+ r'\[([1-9][0-9]*\.[0-9]{3})\]:' # timestamp
+ r'(?:\s\[ptp4l\.\d\..*\])?', # configuration file name
r'CLOCK_REALTIME phc offset\s*',
r'(-?[0-9]+)', # time error
r'(\S+)', # state
r'freq\s*',
r'([-+]?[0-9]+)', # frequency error
r'delay\s*',
r'(-?[0-9]+)' # delay
+ r'\s*.*$'))

def __init__(self):
super().__init__()
Expand Down
4 changes: 2 additions & 2 deletions src/vse_sync_pp/parsers/ts2phc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def build_regexp(interface=None):
If `interface` then only parse lines for the specified interface.
"""
return r''.join((
r'^ts2phc' + # noqa: W504
r'\[([1-9][0-9]*\.[0-9]{3})\]:', # timestamp
r'^ts2phc'
+ r'\[([1-9][0-9]*\.[0-9]{3})\]:', # timestamp
r'(?:\s\[ts2phc\.\d\..*\])?', # configuration file name
fr'\s({interface})' if interface else r'\s(\S+)', # interface
r'\smaster offset\s*',
Expand Down
1 change: 0 additions & 1 deletion src/vse_sync_pp/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def build_sources(parsers, filename, encoding='utf-8'):
for obj in yaml.safe_load_all(fid.read()):
source = obj['source']
contains = obj['contains']
# pylint: disable=consider-using-with
file = stdin if source == '-' else open(source, encoding=encoding)
if contains == 'muxed':
yield muxed(file, parsers)
Expand Down
3 changes: 1 addition & 2 deletions tests/vse_sync_pp/analyzers/test_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class AnalyzerTestBuilder(type):
timestamp, duration, analysis giving test config, input data,
expected outputs
"""
def __new__(cls, name, bases, dct): # pylint: disable=bad-mcs-classmethod-argument
def __new__(cls, name, bases, dct):
constructor = dct['constructor']
fqname = make_fqname(constructor)
dct.update({
Expand Down Expand Up @@ -180,7 +180,6 @@ def method(self):
@staticmethod
def make_test_result(constructor, fqname, expect):
"""Make a function testing analyzer test result and analysis"""
# pylint: disable=too-many-arguments
@params(*expect)
def method(self, dct):
"""Test analyzer test result and analysis"""
Expand Down
10 changes: 5 additions & 5 deletions tests/vse_sync_pp/parsers/test_gnss.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ class TestTimeErrorParser(TestCase, metaclass=ParserTestBuilder):
elems = ('timestamp', 'state', 'terror')
accept = (
('681011.839,5,-3',
(Decimal('681011.839'), 5, -3),),
(Decimal('681011.839'), 5, -3)),
('2023-06-16T17:01:11.131Z,1,400',
(Decimal('1686934871.131'), 1, 400),),
(Decimal('1686934871.131'), 1, 400)),
('2023-06-16T17:01:11.131282-00:00,2,399',
(Decimal('1686934871.131282'), 2, 399),),
(Decimal('1686934871.131282'), 2, 399)),
('2023-06-16T17:01:11.131282269+00:00,3,398',
(Decimal('1686934871.131282269'), 3, 398),),
(Decimal('1686934871.131282269'), 3, 398)),
('681011.839,5,-3,-2.72',
(Decimal('681011.839'), 5, -3),),
(Decimal('681011.839'), 5, -3)),
)
reject = (
'foo bar baz',
Expand Down
2 changes: 1 addition & 1 deletion tests/vse_sync_pp/parsers/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ParserTestBuilder(type):
`file` - a 2-tuple (lines, expect) the parser must parse `expect` from
`lines` presented as a file object
"""
def __new__(cls, name, bases, dct): # pylint: disable=bad-mcs-classmethod-argument
def __new__(cls, name, bases, dct):
constructor = dct['constructor']
fqname = make_fqname(constructor)
dct.update({
Expand Down

0 comments on commit f3a8910

Please sign in to comment.