diff --git a/bootstrap.py b/bootstrap.py index 6f5193e..b6312c3 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -129,7 +129,7 @@ if version is None and not options.accept_buildout_test_releases: def _final_version(parsed_version): for part in parsed_version: - if (part[:1] == '*') and (part not in _final_parts): + if (part.startswith('*')) and (part not in _final_parts): return False return True index = setuptools.package_index.PackageIndex( diff --git a/src/icalendar/prop.py b/src/icalendar/prop.py index c826584..2331228 100644 --- a/src/icalendar/prop.py +++ b/src/icalendar/prop.py @@ -1042,7 +1042,7 @@ class vMonth(int): month_index = int(month) leap = False else: - if not month[-1] == "L" and month[:-1].isdigit(): + if month[-1] != "L" and month[:-1].isdigit(): raise ValueError(f"Invalid month: {month!r}") month_index = int(month[:-1]) leap = True diff --git a/src/icalendar/tests/prop/test_unit.py b/src/icalendar/tests/prop/test_unit.py index 87a725b..ce47811 100644 --- a/src/icalendar/tests/prop/test_unit.py +++ b/src/icalendar/tests/prop/test_unit.py @@ -24,9 +24,9 @@ class TestProp(unittest.TestCase): from icalendar.prop import vDDDLists dt_list = vDDDLists.from_ical("19960402T010000Z") - self.assertTrue(isinstance(dt_list, list)) + self.assertIsInstance(dt_list, list) self.assertEqual(len(dt_list), 1) - self.assertTrue(isinstance(dt_list[0], datetime)) + self.assertIsInstance(dt_list[0], datetime) self.assertEqual(str(dt_list[0]), "1996-04-02 01:00:00+00:00") p = "19960402T010000Z,19960403T010000Z,19960404T010000Z" @@ -45,7 +45,7 @@ class TestProp(unittest.TestCase): self.assertEqual(dt_list.to_ical(), b"20000101T000000,20001111T000000") instance = vDDDLists([]) - self.assertFalse(instance == "value") + self.assertNotEqual(instance, "value") def test_prop_vDate(self): from icalendar.prop import vDate @@ -149,7 +149,7 @@ class TestProp(unittest.TestCase): self.assertEqual(vRecur(r).to_ical(), b"FREQ=DAILY;COUNT=10;INTERVAL=2") r = vRecur.from_ical( - "FREQ=YEARLY;INTERVAL=2;BYMONTH=1;BYDAY=-SU;" "BYHOUR=8,9;BYMINUTE=30" + "FREQ=YEARLY;INTERVAL=2;BYMONTH=1;BYDAY=-SU;BYHOUR=8,9;BYMINUTE=30" ) self.assertEqual( r, @@ -165,7 +165,7 @@ class TestProp(unittest.TestCase): self.assertEqual( vRecur(r).to_ical(), - b"FREQ=YEARLY;INTERVAL=2;BYMINUTE=30;BYHOUR=8,9;BYDAY=-SU;" b"BYMONTH=1", + b"FREQ=YEARLY;INTERVAL=2;BYMINUTE=30;BYHOUR=8,9;BYDAY=-SU;BYMONTH=1", ) r = vRecur.from_ical("FREQ=WEEKLY;INTERVAL=1;BYWEEKDAY=TH") diff --git a/src/icalendar/tests/test_icalendar.py b/src/icalendar/tests/test_icalendar.py index 36314ae..531eb90 100644 --- a/src/icalendar/tests/test_icalendar.py +++ b/src/icalendar/tests/test_icalendar.py @@ -40,7 +40,7 @@ class IcalendarTestCase(unittest.TestCase): ) self.assertEqual( Contentlines.from_ical( - "A faked\r\n long line\r\nAnd another " "lin\r\n\te that is folded\r\n" + "A faked\r\n long line\r\nAnd another lin\r\n\te that is folded\r\n" ), ["A faked long line", "And another line that is folded", ""], ) @@ -112,7 +112,7 @@ class IcalendarTestCase(unittest.TestCase): ) c = Contentline( - "ATTENDEE;CN=Max Rasmussen;ROLE=REQ-PARTICIPANT:" "MAILTO:maxm@example.com" + "ATTENDEE;CN=Max Rasmussen;ROLE=REQ-PARTICIPANT:MAILTO:maxm@example.com" ) self.assertEqual( c.parts(), @@ -124,7 +124,7 @@ class IcalendarTestCase(unittest.TestCase): ) self.assertEqual( c.to_ical().decode("utf-8"), - "ATTENDEE;CN=Max Rasmussen;ROLE=REQ-PARTICIPANT:" "MAILTO:maxm@example.com", + "ATTENDEE;CN=Max Rasmussen;ROLE=REQ-PARTICIPANT:MAILTO:maxm@example.com", ) # and back again diff --git a/src/icalendar/tests/test_unit_caselessdict.py b/src/icalendar/tests/test_unit_caselessdict.py index a3126ee..fefbc4d 100644 --- a/src/icalendar/tests/test_unit_caselessdict.py +++ b/src/icalendar/tests/test_unit_caselessdict.py @@ -115,10 +115,10 @@ class TestCaselessdict(unittest.TestCase): self.assertEqual(ncd.get("key1"), "val1") self.assertEqual(ncd.get("key3", "NOT FOUND"), "val3") self.assertEqual(ncd.get("key4", "NOT FOUND"), "NOT FOUND") - self.assertTrue("key4" in ncd) + self.assertIn("key4", ncd) del ncd["key4"] - self.assertFalse("key4" in ncd) + self.assertNotIn("key4", ncd) ncd.update({"key5": "val5", "KEY6": "val6", "KEY5": "val7"}) self.assertEqual(ncd["key6"], "val6") diff --git a/src/icalendar/tests/test_unit_parser_tools.py b/src/icalendar/tests/test_unit_parser_tools.py index 8eea790..8f3f378 100644 --- a/src/icalendar/tests/test_unit_parser_tools.py +++ b/src/icalendar/tests/test_unit_parser_tools.py @@ -12,7 +12,7 @@ class TestParserTools(unittest.TestCase): self.assertEqual(to_unicode(b"\xc6\xb5"), "\u01b5") self.assertEqual(to_unicode(b"\xc6\xb5", encoding="ascii"), "\u01b5") self.assertEqual(to_unicode(1), 1) - self.assertEqual(to_unicode(None), None) + self.assertIsNone(to_unicode(None)) def test_parser_tools_from_unicode(self): self.assertEqual(from_unicode("\u01b5", encoding="ascii"), b"\xc6\xb5") diff --git a/src/icalendar/tests/test_unit_tools.py b/src/icalendar/tests/test_unit_tools.py index b396e55..e0d8db4 100644 --- a/src/icalendar/tests/test_unit_tools.py +++ b/src/icalendar/tests/test_unit_tools.py @@ -13,20 +13,20 @@ class TestTools(unittest.TestCase): txt = uid.to_ical() length = 15 + 1 + 16 + 1 + 11 - self.assertTrue(len(txt) == length) - self.assertTrue(b"@example.com" in txt) + self.assertEqual(len(txt), length) + self.assertIn(b"@example.com", txt) # You should at least insert your own hostname to be more compliant uid = g.uid("Example.ORG") txt = uid.to_ical() - self.assertTrue(len(txt) == length) - self.assertTrue(b"@Example.ORG" in txt) + self.assertEqual(len(txt), length) + self.assertIn(b"@Example.ORG", txt) # You can also insert a path or similar uid = g.uid("Example.ORG", "/path/to/content") txt = uid.to_ical() - self.assertTrue(len(txt) == length) - self.assertTrue(b"-/path/to/content@Example.ORG" in txt) + self.assertEqual(len(txt), length) + self.assertIn(b"-/path/to/content@Example.ORG", txt) @pytest.mark.parametrize( diff --git a/src/icalendar/timezone/equivalent_timezone_ids.py b/src/icalendar/timezone/equivalent_timezone_ids.py index 63da737..d59ad03 100644 --- a/src/icalendar/timezone/equivalent_timezone_ids.py +++ b/src/icalendar/timezone/equivalent_timezone_ids.py @@ -123,7 +123,7 @@ def main( with file.open("w") as f: f.write(f"'''This file is automatically generated by {Path(__file__).name}'''\n") f.write("import datetime\n\n") - f.write(f"\nlookup = ") + f.write("\nlookup = ") pprint(lookup, stream=f) f.write("\n\n__all__ = ['lookup']\n") diff --git a/src/icalendar/timezone/tzp.py b/src/icalendar/timezone/tzp.py index 39dbb9c..677d6e9 100644 --- a/src/icalendar/timezone/tzp.py +++ b/src/icalendar/timezone/tzp.py @@ -105,16 +105,16 @@ class TZP: """ return tzid.strip("/") - def timezone(self, id: str) -> Optional[datetime.tzinfo]: + def timezone(self, tz_id: str) -> Optional[datetime.tzinfo]: """Return a timezone with an id or None if we cannot find it.""" - _unclean_id = id - id = self.clean_timezone_id(id) - tz = self.__provider.timezone(id) + _unclean_id = tz_id + tz_id = self.clean_timezone_id(tz_id) + tz = self.__provider.timezone(tz_id) if tz is not None: return tz - if id in WINDOWS_TO_OLSON: - tz = self.__provider.timezone(WINDOWS_TO_OLSON[id]) - return tz or self.__provider.timezone(_unclean_id) or self.__tz_cache.get(id) + if tz_id in WINDOWS_TO_OLSON: + tz = self.__provider.timezone(WINDOWS_TO_OLSON[tz_id]) + return tz or self.__provider.timezone(_unclean_id) or self.__tz_cache.get(tz_id) def uses_pytz(self) -> bool: """Whether we use pytz at all."""