Skip to content

Commit

Permalink
Manually address E501 and B018
Browse files Browse the repository at this point in the history
  • Loading branch information
rcomer committed Nov 14, 2023
1 parent e255333 commit a90d593
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
5 changes: 3 additions & 2 deletions cf_units/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ def suppress_errors():
except _ud.UdunitsError as e:
error_msg = ': "%s"' % e.error_msg() if e.errnum else ""
raise OSError(
f"[{e.status_msg()}] Failed to open UDUNITS-2 XML unit database{error_msg}"
f"[{e.status_msg()}] "
f"Failed to open UDUNITS-2 XML unit database{error_msg}"
)


Expand Down Expand Up @@ -1670,7 +1671,7 @@ def change_calendar(self, calendar):
>>> u.change_calendar('standard')
Unit('days since 1499-12-23T00:00:00', calendar='standard')
"""
""" # NOQA E501
if not self.is_time_reference():
raise ValueError("unit is not a time reference")

Expand Down
3 changes: 2 additions & 1 deletion cf_units/_udunits2_parser/parser/udunits2Lexer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Generated from /home/ruth/git_stuff/cf-units/cf_units/_udunits2_parser/parser/udunits2Lexer.g4 by ANTLR 4.11.1
# Generated from cf_units/_udunits2_parser/parser/udunits2Lexer.g4 by
# ANTLR 4.11.1
import sys

from antlr4 import *
Expand Down
2 changes: 1 addition & 1 deletion cf_units/_udunits2_parser/parser/udunits2Parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated from /home/ruth/git_stuff/cf-units/cf_units/_udunits2_parser/udunits2Parser.g4 by ANTLR 4.11.1
# Generated from cf_units/_udunits2_parser/udunits2Parser.g4 by ANTLR 4.11.1
import sys

from antlr4 import *
Expand Down
5 changes: 3 additions & 2 deletions cf_units/_udunits2_parser/parser/udunits2ParserVisitor.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Generated from /home/ruth/git_stuff/cf-units/cf_units/_udunits2_parser/udunits2Parser.g4 by ANTLR 4.11.1
# Generated from cf_units/_udunits2_parser/udunits2Parser.g4 by ANTLR 4.11.1
from antlr4 import *

if __name__ is not None and "." in __name__:
from .udunits2Parser import udunits2Parser
else:
from udunits2Parser import udunits2Parser

# This class defines a complete generic visitor for a parse tree produced by udunits2Parser.
# This class defines a complete generic visitor for a parse tree produced by
# udunits2Parser.


class udunits2ParserVisitor(ParseTreeVisitor):
Expand Down
4 changes: 2 additions & 2 deletions cf_units/tests/integration/parse/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def test_known_issues(_, unit_str, expected):
# These are the cases that don't work yet but which do work with udunits.

# Make sure udunits can read it.
cf_units.Unit(unit_str).symbol
cf_units.Unit(unit_str).symbol # noqa: B018

if isinstance(expected, type) and issubclass(expected, Exception):
with pytest.raises(SyntaxError):
Expand Down Expand Up @@ -293,7 +293,7 @@ def test_invalid_syntax_units(_, unit_str):
# allowed with our grammar.

with pytest.raises(ValueError):
cf_units.Unit(unit_str).symbol
cf_units.Unit(unit_str).symbol # noqa: B018

with pytest.raises(SyntaxError):
normalize(unit_str)
18 changes: 12 additions & 6 deletions cf_units/tests/integration/test__Unit_num2date.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ def test_simple_360_day(self):
self.udays,
self.udays,
]
# Expected results in (days, seconds, microseconds) delta from unit epoch.
# Expected results in (days, seconds, microseconds) delta from unit
# epoch.
expected = [
(0, nums[0], 0),
(0, nums[1], 0),
Expand Down Expand Up @@ -218,7 +219,8 @@ def test_fractional_360_day(self):
self.udays,
self.udays,
]
# Expected results in (days, seconds, microseconds) delta from unit epoch.
# Expected results in (days, seconds, microseconds) delta from unit
# epoch.
expected = [
(0, nums[0] * 60, 0),
(0, nums[1] * 60, 0),
Expand All @@ -234,7 +236,8 @@ def test_fractional_second_360_day(self):
self.setup_units("360_day")
nums = [0.25, 0.5, 0.75, 1.5, 2.5, 3.5, 4.5]
units = [self.useconds] * 7
# Expected results in (days, seconds, microseconds) delta from unit epoch.
# Expected results in (days, seconds, microseconds) delta from unit
# epoch.
expected = [
(0, 0, 250000),
(0, 0, 500000),
Expand Down Expand Up @@ -273,7 +276,8 @@ def test_simple_365_day(self):
self.udays,
self.udays,
]
# Expected results in (days, seconds, microseconds) delta from unit epoch.
# Expected results in (days, seconds, microseconds) delta from unit
# epoch.
expected = [
(0, nums[0], 0),
(0, nums[1], 0),
Expand Down Expand Up @@ -305,7 +309,8 @@ def test_fractional_365_day(self):
self.udays,
self.udays,
]
# Expected results in (days, seconds, microseconds) delta from unit epoch.
# Expected results in (days, seconds, microseconds) delta from unit
# epoch.
expected = [
(0, nums[0] * 60, 0),
(0, nums[1] * 60, 0),
Expand All @@ -321,7 +326,8 @@ def test_fractional_second_365_day(self):
self.setup_units("365_day")
nums = [0.25, 0.5, 0.75, 1.5, 2.5, 3.5, 4.5]
units = [self.useconds] * 7
# Expected results in (days, seconds, microseconds) delta from unit epoch.
# Expected results in (days, seconds, microseconds) delta from unit
# epoch.
expected = [
(0, 0, 250000),
(0, 0, 500000),
Expand Down

0 comments on commit a90d593

Please sign in to comment.