core: cleanup deprecations, exclude from type checking and show runtime warnings
among affected things: - core.common.assert_never - core.common.cproperty - core.common.isoparse - core.common.mcachew - core.common.the - core.common.tzdatetime - core.compat.sqlite_backup
This commit is contained in:
parent
a7439c7846
commit
973c4205df
24 changed files with 118 additions and 103 deletions
|
@ -1,7 +1,7 @@
|
|||
from datetime import datetime
|
||||
from typing import Callable, cast
|
||||
from typing import Callable, Literal, cast
|
||||
|
||||
from ...core.common import tzdatetime, Literal
|
||||
from my.core.common import datetime_aware
|
||||
|
||||
|
||||
'''
|
||||
|
@ -30,7 +30,11 @@ def default_policy() -> TzPolicy:
|
|||
return 'keep'
|
||||
|
||||
|
||||
def localize_with_policy(lfun: Callable[[datetime], tzdatetime], dt: datetime, policy: TzPolicy=default_policy()) -> tzdatetime:
|
||||
def localize_with_policy(
|
||||
lfun: Callable[[datetime], datetime_aware],
|
||||
dt: datetime,
|
||||
policy: TzPolicy=default_policy()
|
||||
) -> datetime_aware:
|
||||
tz = dt.tzinfo
|
||||
if tz is None:
|
||||
return lfun(dt)
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
Timezone data provider, used to localize timezone-unaware timestamps for other modules
|
||||
'''
|
||||
from datetime import datetime
|
||||
from ...core.common import tzdatetime
|
||||
from my.core.common import datetime_aware
|
||||
|
||||
# todo hmm, kwargs isn't mypy friendly.. but specifying types would require duplicating default args. uhoh
|
||||
def localize(dt: datetime, **kwargs) -> tzdatetime:
|
||||
def localize(dt: datetime, **kwargs) -> datetime_aware:
|
||||
# todo document patterns for combining multiple data sources
|
||||
# e.g. see https://github.com/karlicoss/HPI/issues/89#issuecomment-716495136
|
||||
from . import via_location as L
|
||||
|
|
|
@ -17,8 +17,8 @@ from typing import Iterator, Optional, Tuple, Any, List, Iterable, Set, Dict
|
|||
|
||||
import pytz
|
||||
|
||||
from my.core.cachew import mcachew
|
||||
from my.core import make_logger, stat, Stats, datetime_aware
|
||||
from my.core.common import mcachew
|
||||
from my.core.source import import_source
|
||||
from my.core.warnings import high
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue