-
Notifications
You must be signed in to change notification settings - Fork 287
Closed
Description
I have this class method:
@classmethod
def _adjust_instance_using_tzinfo(cls, instance: datetime) -> datetime:
if cls._mock_tzinfo:
offset = cls._mock_tzinfo.utcoffset(instance)
if offset is None:
raise TypeError('tzinfo with .utcoffset() returning None is not supported')
instance = instance - offset
return instance
...where pytype complains but mypy does not, and it feels like the pytype complaint is erroneous:
[10/35] check testfixtures.datetime
FAILED: /Users/chris/vcs/git/testfixtures/.pytype/pyi/testfixtures/datetime.pyi
/Users/chris/virtualenvs/testfixtures_312/bin/python -m pytype.main --disable import-error --imports_info /Users/chris/vcs/git/testfixtures/.pytype/imports/testfixtures.datetime.imports --module-name testfixtures.datetime --platform darwin -V 3.12 -o /Users/chris/vcs/git/testfixtures/.pytype/pyi/testfixtures/datetime.pyi --analyze-annotated --nofail --quick /Users/chris/vcs/git/testfixtures/testfixtures/datetime.py
/Users/chris/vcs/git/testfixtures/testfixtures/datetime.py:264:22: error: in _adjust_instance_using_tzinfo: No attribute 'utcoffset' on None [attribute-error]
In Optional[datetime.tzinfo]
offset = cls._mock_tzinfo.utcoffset(instance)
~~~~~~~~~~~~~~~~~~~~~~~~~~
Even if I change the guarding if
block to be if cls._mock_tzinfo is not None
, the complaint remains.
Harmon758
Metadata
Metadata
Assignees
Labels
No labels