]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Further de-linting of zoneinfo module (#20499)
authorPaul Ganssle <paul@ganssle.io>
Fri, 29 May 2020 13:34:30 +0000 (09:34 -0400)
committerGitHub <noreply@github.com>
Fri, 29 May 2020 13:34:30 +0000 (09:34 -0400)
* Remove unused imports in zoneinfo

* Remove unused variables in zoneinfo

* Remove else after raise

Lib/test/test_zoneinfo/test_zoneinfo.py
Lib/zoneinfo/_common.py
Lib/zoneinfo/_tzpath.py
Lib/zoneinfo/_zoneinfo.py

index fe2c380c51442eedb0ca05f166b1f84e192df8b5..1f1fa60f1ffc1fe3dadf16ec20a13e594c1fe833 100644 (file)
@@ -19,12 +19,7 @@ from datetime import date, datetime, time, timedelta, timezone
 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()
 
@@ -365,7 +360,6 @@ class ZoneInfoTest(TzPathUserMixin, ZoneInfoTestBase):
                     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):
@@ -927,7 +921,7 @@ class TZStrTest(ZoneInfoTestBase):
         # 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
@@ -952,7 +946,6 @@ class TZStrTest(ZoneInfoTestBase):
         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)
index 3d35d4f4b463f8d0dcff7ff9040560757d58ffe8..41c898f37e4f85939e5c13affa638ca59563844c 100644 (file)
@@ -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)
 
index 9e381b6e4434bde6d79ad435b843962c125d78c9..9513611c17738e14c87260601c2632389566d05e 100644 (file)
@@ -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:
index b207dd346fe2569a83b96713e40573196bf877e1..7b1718a0676e1786b0859282940ba1fb568a8651 100644 (file)
@@ -4,7 +4,7 @@ import collections
 import functools
 import re
 import weakref
-from datetime import datetime, timedelta, timezone, tzinfo
+from datetime import datetime, timedelta, tzinfo
 
 from . import _common, _tzpath