Skip to content

Commit

Permalink
general: deprecate some old methods by hiding behind TYPE_CHECKING
Browse files Browse the repository at this point in the history
  • Loading branch information
karlicoss committed Oct 30, 2023
1 parent ea195e3 commit 3d4ee9b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
8 changes: 5 additions & 3 deletions my/hypothesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
]
from dataclasses import dataclass
from pathlib import Path
from typing import Iterator, Sequence
from typing import Iterator, Sequence, TYPE_CHECKING

from my.core import (
get_files,
Expand Down Expand Up @@ -69,5 +69,7 @@ def stats() -> Stats:
}


get_highlights = highlights # todo deprecate
get_pages = pages # todo deprecate
if not TYPE_CHECKING:
# "deprecate" by hiding from mypy
get_highlights = highlights
get_pages = pages
7 changes: 5 additions & 2 deletions my/pocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
'git+https://github.com/karlicoss/pockexport',
]
from dataclasses import dataclass
from typing import TYPE_CHECKING

from .core import Paths

Expand Down Expand Up @@ -61,5 +62,7 @@ def stats() -> Stats:


# todo deprecate?
def get_articles() -> Sequence[Article]:
return list(articles())
if not TYPE_CHECKING:
# "deprecate" by hiding from mypy
def get_articles() -> Sequence[Article]:
return list(articles())
4 changes: 3 additions & 1 deletion my/polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,6 @@ def get_entries() -> List[Result]:


## deprecated
Error = Exception # for backwards compat with Orger; can remove later
if not TYPE_CHECKING:
# "deprecate" by hiding from mypy
Error = Exception # for backwards compat with Orger; can remove later
6 changes: 4 additions & 2 deletions my/youtube/takeout.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import NamedTuple, List, Iterable
from typing import NamedTuple, List, Iterable, TYPE_CHECKING

from ..core import datetime_aware, Res, LazyLogger
from ..core.compat import removeprefix
Expand Down Expand Up @@ -99,7 +99,9 @@ def stats() -> Stats:

### deprecated stuff (keep in my.media.youtube)

get_watched = watched
if not TYPE_CHECKING:
# "deprecate" by hiding from mypy
get_watched = watched


def _watched_legacy() -> Iterable[Watched]:
Expand Down

0 comments on commit 3d4ee9b

Please sign in to comment.