Skip to content

Commit 7c092ed

Browse files
committed
Apply changes required by flake8 plugins
1 parent efad336 commit 7c092ed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1050
-1040
lines changed

.flake8

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
max-line-length = 88
33
per-file-ignores =
44
# F401: Module imported but unused
5-
__init__.py:F401
5+
# TC001: Move import into type checking block
6+
__init__.py:F401, TC001
67
# F811: Redefinition of unused name from line n
78
pendulum/tz/timezone.py:F811
89
min_python_version = 3.7.0

build.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@ def build_extension(self, ext):
5151
build_ext.build_extension(self, ext)
5252
except (CCompilerError, DistutilsExecError, DistutilsPlatformError, ValueError):
5353
print(
54-
' Unable to build the "{}" C extension, '
55-
"Pendulum will use the pure python version of the extension.".format(
56-
ext.name
57-
)
54+
f' Unable to build the "{ext.name}" C extension, '
55+
"Pendulum will use the pure python version of the extension."
5856
)
5957

6058

clock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ class WindowsTzDump(Command):
252252

253253
def handle(self):
254254
raw_tznames = get_global("windows_zone_mapping")
255-
sorted_names = sorted(list(raw_tznames.keys()))
255+
sorted_names = sorted(raw_tznames.keys())
256256

257257
tznames = {}
258258
for name in sorted_names:

pendulum/__init__.py

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,52 @@
55
from typing import Optional
66
from typing import Union
77

8-
from .__version__ import __version__
9-
from .constants import DAYS_PER_WEEK
10-
from .constants import FRIDAY
11-
from .constants import HOURS_PER_DAY
12-
from .constants import MINUTES_PER_HOUR
13-
from .constants import MONDAY
14-
from .constants import MONTHS_PER_YEAR
15-
from .constants import SATURDAY
16-
from .constants import SECONDS_PER_DAY
17-
from .constants import SECONDS_PER_HOUR
18-
from .constants import SECONDS_PER_MINUTE
19-
from .constants import SUNDAY
20-
from .constants import THURSDAY
21-
from .constants import TUESDAY
22-
from .constants import WEDNESDAY
23-
from .constants import WEEKS_PER_YEAR
24-
from .constants import YEARS_PER_CENTURY
25-
from .constants import YEARS_PER_DECADE
26-
from .date import Date
27-
from .datetime import DateTime
28-
from .duration import Duration
29-
from .formatting import Formatter
30-
from .helpers import format_diff
31-
from .helpers import get_locale
32-
from .helpers import get_test_now
33-
from .helpers import has_test_now
34-
from .helpers import locale
35-
from .helpers import set_locale
36-
from .helpers import set_test_now
37-
from .helpers import test
38-
from .helpers import week_ends_at
39-
from .helpers import week_starts_at
40-
from .parser import parse
41-
from .period import Period
42-
from .time import Time
43-
from .tz import POST_TRANSITION
44-
from .tz import PRE_TRANSITION
45-
from .tz import TRANSITION_ERROR
46-
from .tz import UTC
47-
from .tz import local_timezone
48-
from .tz import set_local_timezone
49-
from .tz import test_local_timezone
50-
from .tz import timezone
51-
from .tz import timezones
52-
from .tz.timezone import FixedTimezone
53-
from .tz.timezone import Timezone
8+
from pendulum.__version__ import __version__
9+
from pendulum.constants import DAYS_PER_WEEK
10+
from pendulum.constants import FRIDAY
11+
from pendulum.constants import HOURS_PER_DAY
12+
from pendulum.constants import MINUTES_PER_HOUR
13+
from pendulum.constants import MONDAY
14+
from pendulum.constants import MONTHS_PER_YEAR
15+
from pendulum.constants import SATURDAY
16+
from pendulum.constants import SECONDS_PER_DAY
17+
from pendulum.constants import SECONDS_PER_HOUR
18+
from pendulum.constants import SECONDS_PER_MINUTE
19+
from pendulum.constants import SUNDAY
20+
from pendulum.constants import THURSDAY
21+
from pendulum.constants import TUESDAY
22+
from pendulum.constants import WEDNESDAY
23+
from pendulum.constants import WEEKS_PER_YEAR
24+
from pendulum.constants import YEARS_PER_CENTURY
25+
from pendulum.constants import YEARS_PER_DECADE
26+
from pendulum.date import Date
27+
from pendulum.datetime import DateTime
28+
from pendulum.duration import Duration
29+
from pendulum.formatting import Formatter
30+
from pendulum.helpers import format_diff
31+
from pendulum.helpers import get_locale
32+
from pendulum.helpers import get_test_now
33+
from pendulum.helpers import has_test_now
34+
from pendulum.helpers import locale
35+
from pendulum.helpers import set_locale
36+
from pendulum.helpers import set_test_now
37+
from pendulum.helpers import test
38+
from pendulum.helpers import week_ends_at
39+
from pendulum.helpers import week_starts_at
40+
from pendulum.parser import parse
41+
from pendulum.period import Period
42+
from pendulum.time import Time
43+
from pendulum.tz import POST_TRANSITION
44+
from pendulum.tz import PRE_TRANSITION
45+
from pendulum.tz import TRANSITION_ERROR
46+
from pendulum.tz import UTC
47+
from pendulum.tz import local_timezone
48+
from pendulum.tz import set_local_timezone
49+
from pendulum.tz import test_local_timezone
50+
from pendulum.tz import timezone
51+
from pendulum.tz import timezones
52+
from pendulum.tz.timezone import FixedTimezone
53+
from pendulum.tz.timezone import Timezone
5454

5555

5656
_TEST_NOW: DateTime | None = None

pendulum/_extensions/helpers.py

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55

66
from collections import namedtuple
77

8-
from ..constants import DAY_OF_WEEK_TABLE
9-
from ..constants import DAYS_PER_L_YEAR
10-
from ..constants import DAYS_PER_MONTHS
11-
from ..constants import DAYS_PER_N_YEAR
12-
from ..constants import EPOCH_YEAR
13-
from ..constants import MONTHS_OFFSETS
14-
from ..constants import SECS_PER_4_YEARS
15-
from ..constants import SECS_PER_100_YEARS
16-
from ..constants import SECS_PER_400_YEARS
17-
from ..constants import SECS_PER_DAY
18-
from ..constants import SECS_PER_HOUR
19-
from ..constants import SECS_PER_MIN
20-
from ..constants import SECS_PER_YEAR
21-
from ..constants import TM_DECEMBER
22-
from ..constants import TM_JANUARY
8+
from pendulum.constants import DAY_OF_WEEK_TABLE
9+
from pendulum.constants import DAYS_PER_L_YEAR
10+
from pendulum.constants import DAYS_PER_MONTHS
11+
from pendulum.constants import DAYS_PER_N_YEAR
12+
from pendulum.constants import EPOCH_YEAR
13+
from pendulum.constants import MONTHS_OFFSETS
14+
from pendulum.constants import SECS_PER_4_YEARS
15+
from pendulum.constants import SECS_PER_100_YEARS
16+
from pendulum.constants import SECS_PER_400_YEARS
17+
from pendulum.constants import SECS_PER_DAY
18+
from pendulum.constants import SECS_PER_HOUR
19+
from pendulum.constants import SECS_PER_MIN
20+
from pendulum.constants import SECS_PER_YEAR
21+
from pendulum.constants import TM_DECEMBER
22+
from pendulum.constants import TM_JANUARY
2323

2424

2525
class PreciseDiff(
@@ -30,21 +30,13 @@ class PreciseDiff(
3030
):
3131
def __repr__(self):
3232
return (
33-
"{years} years "
34-
"{months} months "
35-
"{days} days "
36-
"{hours} hours "
37-
"{minutes} minutes "
38-
"{seconds} seconds "
39-
"{microseconds} microseconds"
40-
).format(
41-
years=self.years,
42-
months=self.months,
43-
days=self.days,
44-
hours=self.hours,
45-
minutes=self.minutes,
46-
seconds=self.seconds,
47-
microseconds=self.microseconds,
33+
f"{self.years} years "
34+
f"{self.months} months "
35+
f"{self.days} days "
36+
f"{self.hours} hours "
37+
f"{self.minutes} minutes "
38+
f"{self.seconds} seconds "
39+
f"{self.microseconds} microseconds"
4840
)
4941

5042

pendulum/date.py

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88

99
import pendulum
1010

11-
from .constants import FRIDAY
12-
from .constants import MONDAY
13-
from .constants import MONTHS_PER_YEAR
14-
from .constants import SATURDAY
15-
from .constants import SUNDAY
16-
from .constants import THURSDAY
17-
from .constants import TUESDAY
18-
from .constants import WEDNESDAY
19-
from .constants import YEARS_PER_CENTURY
20-
from .constants import YEARS_PER_DECADE
21-
from .exceptions import PendulumException
22-
from .helpers import add_duration
23-
from .mixins.default import FormattableMixin
24-
from .period import Period
11+
from pendulum.constants import FRIDAY
12+
from pendulum.constants import MONDAY
13+
from pendulum.constants import MONTHS_PER_YEAR
14+
from pendulum.constants import SATURDAY
15+
from pendulum.constants import SUNDAY
16+
from pendulum.constants import THURSDAY
17+
from pendulum.constants import TUESDAY
18+
from pendulum.constants import WEDNESDAY
19+
from pendulum.constants import YEARS_PER_CENTURY
20+
from pendulum.constants import YEARS_PER_DECADE
21+
from pendulum.exceptions import PendulumException
22+
from pendulum.helpers import add_duration
23+
from pendulum.mixins.default import FormattableMixin
24+
from pendulum.period import Period
2525

2626

2727
class Date(FormattableMixin, date):
@@ -105,16 +105,7 @@ def to_formatted_date_string(self):
105105
return self.strftime("%b %d, %Y")
106106

107107
def __repr__(self):
108-
return (
109-
"{klass}("
110-
"{year}, {month}, {day}"
111-
")".format(
112-
klass=self.__class__.__name__,
113-
year=self.year,
114-
month=self.month,
115-
day=self.day,
116-
)
117-
)
108+
return f"{self.__class__.__name__}({self.year}, {self.month}, {self.day})"
118109

119110
# COMPARISONS
120111

@@ -652,9 +643,8 @@ def nth_of(self, unit, nth, day_of_week):
652643
dt = getattr(self, f"_nth_of_{unit}")(nth, day_of_week)
653644
if dt is False:
654645
raise PendulumException(
655-
"Unable to find occurence {} of {} in {}".format(
656-
nth, self._days[day_of_week], unit
657-
)
646+
f"Unable to find occurence {nth}"
647+
f" of {self._days[day_of_week]} in {unit}"
658648
)
659649

660650
return dt
@@ -732,7 +722,7 @@ def _nth_of_month(self, nth, day_of_week):
732722

733723
dt = self.first_of("month")
734724
check = dt.format("YYYY-MM")
735-
for i in range(nth - (1 if dt.day_of_week == day_of_week else 0)):
725+
for _ in range(nth - (1 if dt.day_of_week == day_of_week else 0)):
736726
dt = dt.next(day_of_week)
737727

738728
if dt.format("YYYY-MM") == check:
@@ -789,7 +779,7 @@ def _nth_of_quarter(self, nth, day_of_week):
789779
last_month = dt.month
790780
year = dt.year
791781
dt = dt.first_of("quarter")
792-
for i in range(nth - (1 if dt.day_of_week == day_of_week else 0)):
782+
for _ in range(nth - (1 if dt.day_of_week == day_of_week else 0)):
793783
dt = dt.next(day_of_week)
794784

795785
if last_month < dt.month or year != dt.year:
@@ -842,7 +832,7 @@ def _nth_of_year(self, nth, day_of_week):
842832

843833
dt = self.first_of("year")
844834
year = dt.year
845-
for i in range(nth - (1 if dt.day_of_week == day_of_week else 0)):
835+
for _ in range(nth - (1 if dt.day_of_week == day_of_week else 0)):
846836
dt = dt.next(day_of_week)
847837

848838
if year != dt.year:

pendulum/datetime.py

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,35 @@
77

88
import pendulum
99

10-
from .constants import ATOM
11-
from .constants import COOKIE
12-
from .constants import MINUTES_PER_HOUR
13-
from .constants import MONTHS_PER_YEAR
14-
from .constants import RFC822
15-
from .constants import RFC850
16-
from .constants import RFC1036
17-
from .constants import RFC1123
18-
from .constants import RFC2822
19-
from .constants import RSS
20-
from .constants import SATURDAY
21-
from .constants import SECONDS_PER_DAY
22-
from .constants import SECONDS_PER_MINUTE
23-
from .constants import SUNDAY
24-
from .constants import W3C
25-
from .constants import YEARS_PER_CENTURY
26-
from .constants import YEARS_PER_DECADE
27-
from .date import Date
28-
from .exceptions import PendulumException
29-
from .helpers import add_duration
30-
from .helpers import get_test_now
31-
from .helpers import has_test_now
32-
from .period import Period
33-
from .time import Time
34-
from .tz import UTC
35-
from .tz import local_timezone
36-
from .tz.timezone import FixedTimezone
37-
from .tz.timezone import Timezone
38-
from .utils._compat import PY38
10+
from pendulum.constants import ATOM
11+
from pendulum.constants import COOKIE
12+
from pendulum.constants import MINUTES_PER_HOUR
13+
from pendulum.constants import MONTHS_PER_YEAR
14+
from pendulum.constants import RFC822
15+
from pendulum.constants import RFC850
16+
from pendulum.constants import RFC1036
17+
from pendulum.constants import RFC1123
18+
from pendulum.constants import RFC2822
19+
from pendulum.constants import RSS
20+
from pendulum.constants import SATURDAY
21+
from pendulum.constants import SECONDS_PER_DAY
22+
from pendulum.constants import SECONDS_PER_MINUTE
23+
from pendulum.constants import SUNDAY
24+
from pendulum.constants import W3C
25+
from pendulum.constants import YEARS_PER_CENTURY
26+
from pendulum.constants import YEARS_PER_DECADE
27+
from pendulum.date import Date
28+
from pendulum.exceptions import PendulumException
29+
from pendulum.helpers import add_duration
30+
from pendulum.helpers import get_test_now
31+
from pendulum.helpers import has_test_now
32+
from pendulum.period import Period
33+
from pendulum.time import Time
34+
from pendulum.tz import UTC
35+
from pendulum.tz import local_timezone
36+
from pendulum.tz.timezone import FixedTimezone
37+
from pendulum.tz.timezone import Timezone
38+
from pendulum.utils._compat import PY38
3939

4040

4141
class DateTime(datetime.datetime, Date):
@@ -979,9 +979,8 @@ def nth_of(self, unit: str, nth: int, day_of_week: int) -> DateTime:
979979
dt = getattr(self, f"_nth_of_{unit}")(nth, day_of_week)
980980
if dt is False:
981981
raise PendulumException(
982-
"Unable to find occurence {} of {} in {}".format(
983-
nth, self._days[day_of_week], unit
984-
)
982+
f"Unable to find occurence {nth}"
983+
f" of {self._days[day_of_week]} in {unit}"
985984
)
986985

987986
return dt
@@ -1045,7 +1044,7 @@ def _nth_of_month(self, nth: int, day_of_week: int | None = None) -> DateTime:
10451044

10461045
dt = self.first_of("month")
10471046
check = dt.format("%Y-%M")
1048-
for i in range(nth - (1 if dt.day_of_week == day_of_week else 0)):
1047+
for _ in range(nth - (1 if dt.day_of_week == day_of_week else 0)):
10491048
dt = dt.next(day_of_week)
10501049

10511050
if dt.format("%Y-%M") == check:
@@ -1094,7 +1093,7 @@ def _nth_of_quarter(self, nth: int, day_of_week: int | None = None) -> DateTime:
10941093
last_month = dt.month
10951094
year = dt.year
10961095
dt = dt.first_of("quarter")
1097-
for i in range(nth - (1 if dt.day_of_week == day_of_week else 0)):
1096+
for _ in range(nth - (1 if dt.day_of_week == day_of_week else 0)):
10981097
dt = dt.next(day_of_week)
10991098

11001099
if last_month < dt.month or year != dt.year:
@@ -1133,7 +1132,7 @@ def _nth_of_year(self, nth: int, day_of_week: int | None = None) -> DateTime:
11331132

11341133
dt = self.first_of("year")
11351134
year = dt.year
1136-
for i in range(nth - (1 if dt.day_of_week == day_of_week else 0)):
1135+
for _ in range(nth - (1 if dt.day_of_week == day_of_week else 0)):
11371136
dt = dt.next(day_of_week)
11381137

11391138
if year != dt.year:

0 commit comments

Comments
 (0)