Skip to content

Fix pylint errors #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions adafruit_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ def fromutc(self, dt: "datetime") -> "datetime":

dtoff = dt.utcoffset()
if dtoff is None:
raise ValueError("fromutc() requires a non-None utcoffset() " "result")
raise ValueError("fromutc() requires a non-None utcoffset() result")
return dt + self._offset


Expand Down Expand Up @@ -841,7 +841,7 @@ def __new__(
)
if offset.microseconds != 0 or offset.seconds % 60 != 0:
raise ValueError(
"offset must be a timedelta" " representing a whole number of minutes"
"offset must be a timedelta representing a whole number of minutes"
)
cls._offset = offset
cls._name = name
Expand All @@ -860,14 +860,14 @@ def _create(cls, offset: timedelta, name: Optional[str] = None) -> "timezone":
def utcoffset(self, dt: Optional["datetime"]) -> timedelta:
if isinstance(dt, datetime) or dt is None:
return self._offset
raise TypeError("utcoffset() argument must be a datetime instance" " or None")
raise TypeError("utcoffset() argument must be a datetime instance or None")

def tzname(self, dt: Optional["datetime"]) -> str:
if isinstance(dt, datetime) or dt is None:
if self._name is None:
return self._name_from_offset(self._offset)
return self._name
raise TypeError("tzname() argument must be a datetime instance" " or None")
raise TypeError("tzname() argument must be a datetime instance or None")

# Comparison to other timezone objects
def __eq__(self, other: Any) -> bool:
Expand Down Expand Up @@ -1362,7 +1362,7 @@ def _fromtimestamp(cls, t: float, utc: bool, tz: Optional["tzinfo"]) -> "datetim
result = tz.fromutc(result)
return result

## pylint: disable=arguments-differ
## pylint: disable=arguments-differ, arguments-renamed
@classmethod
def fromtimestamp(
cls, timestamp: float, tz: Optional["tzinfo"] = None
Expand Down
8 changes: 4 additions & 4 deletions tests/test_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# SPDX-License-Identifier: Python-2.0
# Implements a subset of https://github.com/python/cpython/blob/master/Lib/test/datetimetester.py
# NOTE: This test is based off CPython and therefore linting is disabled within this file.
# pylint:disable=invalid-name, no-member, wrong-import-position, undefined-variable, no-self-use, cell-var-from-loop, misplaced-comparison-constant, too-many-public-methods, fixme, import-outside-toplevel, unused-argument, too-few-public-methods
# pylint:disable=invalid-name, no-member, wrong-import-position, undefined-variable, no-self-use, cell-var-from-loop, too-many-public-methods, fixme, import-outside-toplevel, unused-argument, too-few-public-methods
import sys
import unittest

Expand Down Expand Up @@ -225,23 +225,23 @@ def test_strftime(self):

def test_format(self):
dt = cpy_date(2007, 9, 10)
self.assertEqual(dt.__format__(""), str(dt))
self.assertEqual(format(dt, ""), str(dt))

# check that a derived class's __str__() gets called
class A(cpy_date):
def __str__(self):
return "A"

a = A(2007, 9, 10)
self.assertEqual(a.__format__(""), "A")
self.assertEqual(format(a, ""), "A")

# check that a derived class's strftime gets called
class B(cpy_date):
def strftime(self, format_spec):
return "B"

b = B(2007, 9, 10)
self.assertEqual(b.__format__(""), str(dt))
self.assertEqual(format(b, ""), str(dt))

# date strftime not implemented in CircuitPython, skip
"""for fmt in ["m:%m d:%d y:%y",
Expand Down
14 changes: 7 additions & 7 deletions tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,35 +239,35 @@ def test_isoformat_timezone(self):
@unittest.skip("strftime not implemented in datetime")
def test_format(self):
dt = self.theclass(2007, 9, 10, 4, 5, 1, 123)
self.assertEqual(dt.__format__(""), str(dt))
self.assertEqual(format(dt, ""), str(dt))

with self.assertRaisesRegex(TypeError, "must be str, not int"):
dt.__format__(123)
format(dt, 123)

# check that a derived class's __str__() gets called
class A(self.theclass):
def __str__(self):
return "A"

a = A(2007, 9, 10, 4, 5, 1, 123)
self.assertEqual(a.__format__(""), "A")
self.assertEqual(format(a, ""), "A")

# check that a derived class's strftime gets called
class B(self.theclass):
def strftime(self, format_spec):
return "B"

b = B(2007, 9, 10, 4, 5, 1, 123)
self.assertEqual(b.__format__(""), str(dt))
self.assertEqual(format(b, ""), str(dt))

for fmt in [
"m:%m d:%d y:%y",
"m:%m d:%d y:%y H:%H M:%M S:%S",
"%z %Z",
]:
self.assertEqual(dt.__format__(fmt), dt.strftime(fmt))
self.assertEqual(a.__format__(fmt), dt.strftime(fmt))
self.assertEqual(b.__format__(fmt), "B")
self.assertEqual(format(dt, fmt), dt.strftime(fmt))
self.assertEqual(format(a, fmt), dt.strftime(fmt))
self.assertEqual(format(b, fmt), "B")

@unittest.skip("ctime not implemented")
def test_more_ctime(self):
Expand Down
14 changes: 7 additions & 7 deletions tests/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,33 +237,33 @@ def test_strftime(self):
@unittest.skip("strftime not implemented for CircuitPython time objects")
def test_format(self):
t = self.theclass(1, 2, 3, 4)
self.assertEqual(t.__format__(""), str(t))
self.assertEqual(format(t, ""), str(t))

with self.assertRaisesRegex(TypeError, "must be str, not int"):
t.__format__(123)
format(t, 123)

# check that a derived class's __str__() gets called
class A(self.theclass):
def __str__(self):
return "A"

a = A(1, 2, 3, 4)
self.assertEqual(a.__format__(""), "A")
self.assertEqual(format(a, ""), "A")

# check that a derived class's strftime gets called
class B(self.theclass):
def strftime(self, format_spec):
return "B"

b = B(1, 2, 3, 4)
self.assertEqual(b.__format__(""), str(t))
self.assertEqual(format(b, ""), str(t))

for fmt in [
"%H %M %S",
]:
self.assertEqual(t.__format__(fmt), t.strftime(fmt))
self.assertEqual(a.__format__(fmt), t.strftime(fmt))
self.assertEqual(b.__format__(fmt), "B")
self.assertEqual(format(t, fmt), t.strftime(fmt))
self.assertEqual(format(a, fmt), t.strftime(fmt))
self.assertEqual(format(b, fmt), "B")

def test_str(self):
self.assertEqual(str(self.theclass(1, 2, 3, 4)), "01:02:03.000004")
Expand Down