Skip to content

Commit 20d9bc3

Browse files
authored
Simplify N802 suppression for common.py (#2880)
1 parent 6db03e7 commit 20d9bc3

File tree

2 files changed

+33
-32
lines changed

2 files changed

+33
-32
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ target-version = "py39"
5757
line-length = 99
5858
lint.select = [ "E4", "E5", "E7", "E9", "F", "N", "PLE", "S", "T", "TC", "UP", "W" ]
5959
lint.per-file-ignores."scripts/generate_release_notes.py" = [ "T201" ]
60+
lint.per-file-ignores."tests/common.py" = [ "N802" ]
6061
lint.per-file-ignores."tests/test_holiday_base.py" = [ "S301" ]
6162
lint.flake8-errmsg.max-string-length = 99
6263

tests/common.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def _verify_type(self, holidays):
121121
"`holidays` object must be a subclass of `HolidayBase`",
122122
)
123123

124-
def assertAliases(self, cls, *aliases): # noqa: N802
124+
def assertAliases(self, cls, *aliases):
125125
"""Assert aliases match."""
126126
self.assertTrue(
127127
issubclass(cls, HolidayBase), "The entity object must be a subclass of `HolidayBase`"
@@ -132,7 +132,7 @@ def assertAliases(self, cls, *aliases): # noqa: N802
132132
self.assertIsNotNone(alias, type_error_message)
133133
self.assertTrue(issubclass(alias, cls), type_error_message)
134134

135-
def assertDeprecatedSubdivisions(self, message): # noqa: N802
135+
def assertDeprecatedSubdivisions(self, message):
136136
warnings.simplefilter("always", category=DeprecationWarning)
137137
for subdiv in self.test_class._deprecated_subdivisions:
138138
with warnings.catch_warnings(record=True) as ctx:
@@ -142,24 +142,24 @@ def assertDeprecatedSubdivisions(self, message): # noqa: N802
142142
self.assertIn(message, str(warning.message))
143143

144144
# Holiday.
145-
def _assertHoliday(self, instance_name, *args): # noqa: N802
145+
def _assertHoliday(self, instance_name, *args):
146146
"""Helper: assert each date is a holiday."""
147147
holidays, dates = self._parse_arguments(args, instance_name=instance_name)
148148
self._verify_type(holidays)
149149

150150
for dt in dates:
151151
self.assertIn(dt, holidays, dt)
152152

153-
def assertHoliday(self, *args): # noqa: N802
153+
def assertHoliday(self, *args):
154154
"""Assert each date is a holiday."""
155155
self._assertHoliday("holidays", *args)
156156

157-
def assertNonObservedHoliday(self, *args): # noqa: N802
157+
def assertNonObservedHoliday(self, *args):
158158
"""Assert each date is a non-observed holiday."""
159159
self._assertHoliday("holidays_non_observed", *args)
160160

161161
# Holiday dates.
162-
def _assertHolidayDates(self, instance_name, *args): # noqa: N802
162+
def _assertHolidayDates(self, instance_name, *args):
163163
"""Helper: assert holiday dates exactly match expected dates."""
164164
holidays, dates = self._parse_arguments(args, instance_name=instance_name)
165165
self._verify_type(holidays)
@@ -170,16 +170,16 @@ def _assertHolidayDates(self, instance_name, *args): # noqa: N802
170170

171171
self.assertEqual(len(dates), len(holidays.keys()), set(dates).difference(holidays.keys()))
172172

173-
def assertHolidayDates(self, *args): # noqa: N802
173+
def assertHolidayDates(self, *args):
174174
"""Assert holiday dates exactly match expected dates."""
175175
self._assertHolidayDates("holidays", *args)
176176

177-
def assertNonObservedHolidayDates(self, *args): # noqa: N802
177+
def assertNonObservedHolidayDates(self, *args):
178178
"""Assert holiday dates exactly match expected dates."""
179179
self._assertHolidayDates("holidays_non_observed", *args)
180180

181181
# Holiday name.
182-
def _assertHolidayName(self, name, instance_name, *args): # noqa: N802
182+
def _assertHolidayName(self, name, instance_name, *args):
183183
"""Helper: assert either a holiday with a specific name exists or
184184
each holiday name matches an expected one depending on the args nature.
185185
"""
@@ -195,20 +195,20 @@ def _assertHolidayName(self, name, instance_name, *args): # noqa: N802
195195
else:
196196
raise ValueError(f"The {arg} wasn't caught by `assertHolidayName()`")
197197

198-
def assertHolidayName(self, name, *args): # noqa: N802
198+
def assertHolidayName(self, name, *args):
199199
"""Assert either a holiday with a specific name exists or
200200
each holiday name matches an expected one.
201201
"""
202202
self._assertHolidayName(name, "holidays", *args)
203203

204-
def assertNonObservedHolidayName(self, name, *args): # noqa: N802
204+
def assertNonObservedHolidayName(self, name, *args):
205205
"""Assert either a non-observed holiday with a specific name exists or
206206
each non-observed holiday name matches an expected one.
207207
"""
208208
self._assertHolidayName(name, "holidays_non_observed", *args)
209209

210210
# Holidays.
211-
def _assertHolidays(self, instance_name, *args): # noqa: N802
211+
def _assertHolidays(self, instance_name, *args):
212212
"""Helper: assert holidays exactly match expected holidays."""
213213
holidays, expected_holidays = self._parse_arguments(
214214
args, expand_items=False, instance_name=instance_name
@@ -228,15 +228,15 @@ def _assertHolidays(self, instance_name, *args): # noqa: N802
228228
),
229229
)
230230

231-
def assertHolidays(self, *args): # noqa: N802
231+
def assertHolidays(self, *args):
232232
"""Assert holidays exactly match expected holidays."""
233233
self._assertHolidays("holidays", *args)
234234

235-
def assertNonObservedHolidays(self, *args): # noqa: N802
235+
def assertNonObservedHolidays(self, *args):
236236
"""Assert non-observed holidays exactly match expected holidays."""
237237
self._assertHolidays("holidays_non_observed", *args)
238238

239-
def _assertHolidayNameCount(self, name, count, instance_name, *args): # noqa: N802
239+
def _assertHolidayNameCount(self, name, count, instance_name, *args):
240240
"""Helper: assert number of holidays with a specific name in every year matches
241241
expected.
242242
"""
@@ -255,34 +255,34 @@ def _assertHolidayNameCount(self, name, count, instance_name, *args): # noqa: N
255255
f"`{name}` occurs {holiday_count} times in year {year}, should be {count}",
256256
)
257257

258-
def assertHolidayNameCount(self, name, count, *args): # noqa: N802
258+
def assertHolidayNameCount(self, name, count, *args):
259259
"""Assert number of holidays with a specific name in every year matches expected."""
260260
self._assertHolidayNameCount(name, count, "holidays", *args)
261261

262-
def assertNonObservedHolidayNameCount(self, name, count, *args): # noqa: N802
262+
def assertNonObservedHolidayNameCount(self, name, count, *args):
263263
"""Assert number of non-observed holidays with a specific name in every year
264264
matches expected.
265265
"""
266266
self._assertHolidayNameCount(name, count, "holidays_non_observed", *args)
267267

268268
# No holiday.
269-
def _assertNoHoliday(self, instance_name, *args): # noqa: N802
269+
def _assertNoHoliday(self, instance_name, *args):
270270
"""Helper: assert each date is not a holiday."""
271271
holidays, dates = self._parse_arguments(args, instance_name=instance_name)
272272

273273
for dt in dates:
274274
self.assertNotIn(dt, holidays, dt)
275275

276-
def assertNoHoliday(self, *args): # noqa: N802
276+
def assertNoHoliday(self, *args):
277277
"""Assert each date is not a holiday."""
278278
self._assertNoHoliday("holidays", *args)
279279

280-
def assertNoNonObservedHoliday(self, *args): # noqa: N802
280+
def assertNoNonObservedHoliday(self, *args):
281281
"""Assert each date is not a non-observed holiday."""
282282
self._assertNoHoliday("holidays_non_observed", *args)
283283

284284
# No holiday name.
285-
def _assertNoHolidayName(self, name, instance_name, *args): # noqa: N802
285+
def _assertNoHolidayName(self, name, instance_name, *args):
286286
"""Helper: assert a holiday with a specific name doesn't exist."""
287287
holidays, items = self._parse_arguments(
288288
args, instance_name=instance_name, raise_on_empty=False
@@ -302,16 +302,16 @@ def _assertNoHolidayName(self, name, instance_name, *args): # noqa: N802
302302
else:
303303
raise ValueError(f"The {arg} wasn't caught by `assertNoHolidayName()`")
304304

305-
def assertNoHolidayName(self, name, *args): # noqa: N802
305+
def assertNoHolidayName(self, name, *args):
306306
"""Assert a holiday with a specific name doesn't exist."""
307307
self._assertNoHolidayName(name, "holidays", *args)
308308

309-
def assertNoNonObservedHolidayName(self, name, *args): # noqa: N802
309+
def assertNoNonObservedHolidayName(self, name, *args):
310310
"""Assert a non-observed holiday with a specific name doesn't exist."""
311311
self._assertNoHolidayName(name, "holidays_non_observed", *args)
312312

313313
# No holidays.
314-
def _assertNoHolidays(self, instance_name, *args): # noqa: N802
314+
def _assertNoHolidays(self, instance_name, *args):
315315
"""Helper: assert holidays dict is empty."""
316316
holidays, _ = self._parse_arguments(
317317
args, instance_name=instance_name, raise_on_empty=False
@@ -321,15 +321,15 @@ def _assertNoHolidays(self, instance_name, *args): # noqa: N802
321321
self.assertFalse(holidays)
322322
self.assertEqual(0, len(holidays))
323323

324-
def assertNoHolidays(self, *args): # noqa: N802
324+
def assertNoHolidays(self, *args):
325325
"""Assert holidays dict is empty."""
326326
self._assertNoHolidays("holidays", *args)
327327

328-
def assertNoNonObservedHolidays(self, *args): # noqa: N802
328+
def assertNoNonObservedHolidays(self, *args):
329329
"""Assert non-observed holidays dict is empty."""
330330
self._assertNoHolidays("holidays_non_observed", *args)
331331

332-
def _assertLocalizedHolidays(self, localized_holidays, language=None): # noqa: N802
332+
def _assertLocalizedHolidays(self, localized_holidays, language=None):
333333
"""Helper: assert localized holidays match expected names."""
334334
instance = self.test_class(
335335
years=localized_holidays[0][0].split("-")[0],
@@ -356,7 +356,7 @@ def _assertLocalizedHolidays(self, localized_holidays, language=None): # noqa:
356356
f"Please make sure all holiday names are localized: {actual_holidays}",
357357
)
358358

359-
def assertLocalizedHolidays(self, *args): # noqa: N802
359+
def assertLocalizedHolidays(self, *args):
360360
"""Assert localized holidays match expected names."""
361361
arg = args[0]
362362
is_string = isinstance(arg, str)
@@ -442,7 +442,7 @@ def test_code(self):
442442
class SundayHolidays(TestCase):
443443
"""Common class to test countries with Sundays as a holidays."""
444444

445-
def assertSundays(self, cls): # noqa: N802
445+
def assertSundays(self, cls):
446446
holidays = cls(years=1989, include_sundays=True)
447447
self.assertHoliday(holidays, "1989-12-31")
448448
self.assertEqual(53, len([s for s in holidays if s.weekday() == SUN]))
@@ -481,7 +481,7 @@ class WorkingDayTests(TestCase):
481481
"""Common class for testing entity holidays substituted from non-working days."""
482482

483483
# Workday.
484-
def _assertWorkingDay(self, instance_name, *args): # noqa: N802
484+
def _assertWorkingDay(self, instance_name, *args):
485485
"""Helper: assert each date is a working day."""
486486
holidays, dates = self._parse_arguments(args, instance_name=instance_name)
487487
self._verify_type(holidays)
@@ -490,10 +490,10 @@ def _assertWorkingDay(self, instance_name, *args): # noqa: N802
490490
self.assertTrue(holidays._is_weekend(parse(dt)))
491491
self.assertTrue(holidays.is_working_day(dt))
492492

493-
def assertWorkingDay(self, *args): # noqa: N802
493+
def assertWorkingDay(self, *args):
494494
"""Assert each date is a working day."""
495495
self._assertWorkingDay("holidays", *args)
496496

497-
def assertNonObservedWorkingDay(self, *args): # noqa: N802
497+
def assertNonObservedWorkingDay(self, *args):
498498
"""Assert each date is a non-observed working day."""
499499
self._assertWorkingDay("holidays_non_observed", *args)

0 commit comments

Comments
 (0)