Skip to content

Commit

Permalink
Fix typing in rfc822_formatted_time (aio-libs#3927)
Browse files Browse the repository at this point in the history
- Add type annotations to global variables
- Fix handling of unused return values from time.gmtime
- Silence mypy error on return line (it's not yet capable of deducing
  that _cached_formatted_datetime is always defined at the end of the
  function)
  • Loading branch information
AMDmi3 committed Jul 22, 2019
1 parent 42e4043 commit eb57de2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@ def is_ip_address(
return is_ipv4_address(host) or is_ipv6_address(host)


_cached_current_datetime = None
_cached_formatted_datetime = None
_cached_current_datetime: Optional[int] = None
_cached_formatted_datetime: Optional[str] = None


def rfc822_formatted_time() -> str:
Expand All @@ -473,12 +473,12 @@ def rfc822_formatted_time() -> str:
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec")

year, month, day, hh, mm, ss, wd, y, z = time.gmtime(now) # type: ignore # noqa
year, month, day, hh, mm, ss, wd, *_ = time.gmtime(now)
_cached_formatted_datetime = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
_weekdayname[wd], day, _monthname[month], year, hh, mm, ss
)
_cached_current_datetime = now
return _cached_formatted_datetime
return _cached_formatted_datetime # type: ignore


def _weakref_handle(info): # type: ignore
Expand Down

0 comments on commit eb57de2

Please sign in to comment.