Skip to content

Commit

Permalink
Further de-linting of zoneinfo module (pythonGH-20499)
Browse files Browse the repository at this point in the history
* Remove unused imports in zoneinfo

* Remove unused variables in zoneinfo

* Remove else after raise
(cherry picked from commit 364b5ea)

Co-authored-by: Paul Ganssle <paul@ganssle.io>
  • Loading branch information
pganssle authored and miss-islington committed May 29, 2020
1 parent 8fcc147 commit 4e7bcef
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
11 changes: 2 additions & 9 deletions Lib/test/test_zoneinfo/test_zoneinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@
from functools import cached_property

from . import _support as test_support
from ._support import (
OS_ENV_LOCK,
TZPATH_LOCK,
TZPATH_TEST_LOCK,
ZoneInfoTestBase,
)
from ._support import OS_ENV_LOCK, TZPATH_TEST_LOCK, ZoneInfoTestBase

py_zoneinfo, c_zoneinfo = test_support.get_modules()

Expand Down Expand Up @@ -365,7 +360,6 @@ def test_folds_and_gaps(self):
self.assertEqual(dt.dst(), offset.dst, dt)

def test_folds_from_utc(self):
tests = []
for key in self.zones():
zi = self.zone_from_key(key)
with self.subTest(key=key):
Expand Down Expand Up @@ -927,7 +921,7 @@ def populate_tzstr_header(cls):
# the Version 2+ file. In this case, we have no transitions, just
# the tzstr in the footer, so up to the footer, the files are
# identical and we can just write the same file twice in a row.
for i in range(2):
for _ in range(2):
out += b"TZif" # Magic value
out += b"3" # Version
out += b" " * 15 # Reserved
Expand All @@ -952,7 +946,6 @@ def zone_from_tzstr(self, tzstr):
return self.klass.from_file(zonefile, key=tzstr)

def test_tzstr_localized(self):
i = 0
for tzstr, cases in self.test_cases.items():
with self.subTest(tzstr=tzstr):
zi = self.zone_from_tzstr(tzstr)
Expand Down
1 change: 0 additions & 1 deletion Lib/zoneinfo/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def load_data(fobj):
# not by position in the array but by position in the unsplit
# abbreviation string. I suppose this makes more sense in C, which uses
# null to terminate the strings, but it's inconvenient here...
char_total = 0
abbr_vals = {}
abbr_chars = fobj.read(charcnt)

Expand Down
3 changes: 2 additions & 1 deletion Lib/zoneinfo/_tzpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def reset_tzpath(to=None):
f"tzpaths must be a list or tuple, "
+ f"not {type(tzpaths)}: {tzpaths!r}"
)
elif not all(map(os.path.isabs, tzpaths)):

if not all(map(os.path.isabs, tzpaths)):
raise ValueError(_get_invalid_paths_message(tzpaths))
base_tzpath = tzpaths
else:
Expand Down
2 changes: 1 addition & 1 deletion Lib/zoneinfo/_zoneinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import functools
import re
import weakref
from datetime import datetime, timedelta, timezone, tzinfo
from datetime import datetime, timedelta, tzinfo

from . import _common, _tzpath

Expand Down

0 comments on commit 4e7bcef

Please sign in to comment.