You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
I think it's better to use typing hints. That makes code cleaner. See PEP 484.
For example, this part:
def transform_numeral_date(data):
# for example '1397/12/6' or 2018-2-25 which is my birthday :)
if data.find('/') != -1:
_type = 'solar'
else: # assume gregorian
_type = 'gregorian'
data = data.strip().replace('/', '-').split('-')
(year, month, day) = (transform_number(data[0])
,transform_number(data[1])
,transform_number(data[2]))
season = find_season(int(month), _type)
return (year, season, month, day)
Converts to:
from typing import Tuple
def transform_numeral_date(data: str) -> Tuple[int, Tuple[str, int], int, int]:
# for example '1397/12/6' or 2018-2-25 which is my birthday :)
if data.find('/') != -1:
_type = 'solar'
else: # assume gregorian
_type = 'gregorian'
data = data.strip().replace('/', '-').split('-')
(year, month, day) = (transform_number(data[0])
,transform_number(data[1])
,transform_number(data[2]))
season = find_season(int(month), _type)
return (year, season, month, day)
If you think that's OK, I can fix it.
The text was updated successfully, but these errors were encountered:
Hi!
I think it's better to use typing hints. That makes code cleaner. See PEP 484.
For example, this part:
Converts to:
If you think that's OK, I can fix it.
The text was updated successfully, but these errors were encountered: