diff --git a/my/core/common.py b/my/core/common.py index dcd1074..d0b737e 100644 --- a/my/core/common.py +++ b/my/core/common.py @@ -133,8 +133,8 @@ def test_classproperty() -> None: return 'hello' res = C.prop - assert res == 'hello' assert_type(res, str) + assert res == 'hello' # hmm, this doesn't really work with mypy well.. diff --git a/my/core/stats.py b/my/core/stats.py index 08821a2..bfedbd2 100644 --- a/my/core/stats.py +++ b/my/core/stats.py @@ -2,7 +2,7 @@ Helpers for hpi doctor/stats functionality. ''' -import collections +import collections.abc import importlib import inspect import typing diff --git a/my/core/util.py b/my/core/util.py index b48a450..0c596fa 100644 --- a/my/core/util.py +++ b/my/core/util.py @@ -25,7 +25,7 @@ def is_not_hpi_module(module: str) -> Optional[str]: ''' None if a module, otherwise returns reason ''' - import importlib + import importlib.util path: Optional[str] = None try: diff --git a/my/core/utils/itertools.py b/my/core/utils/itertools.py index 023484d..66f82bd 100644 --- a/my/core/utils/itertools.py +++ b/my/core/utils/itertools.py @@ -275,20 +275,18 @@ def test_check_if_hashable() -> None: x1: List[int] = [1, 2] r1 = check_if_hashable(x1) - # tgype: ignore[comparison-overlap] # object should be unchanged - assert r1 is x1 assert_type(r1, Iterable[int]) + assert r1 is x1 x2: Iterator[Union[int, str]] = iter((123, 'aba')) r2 = check_if_hashable(x2) - assert list(r2) == [123, 'aba'] assert_type(r2, Iterable[Union[int, str]]) + assert list(r2) == [123, 'aba'] x3: Tuple[object, ...] = (789, 'aba') r3 = check_if_hashable(x3) - # ttype: ignore[comparison-overlap] # object should be unchanged - assert r3 is x3 assert_type(r3, Iterable[object]) + assert r3 is x3 # object should be unchanged x4: List[Set[int]] = [{1, 2, 3}, {4, 5, 6}] with pytest.raises(Exception): diff --git a/my/google/takeout/html.py b/my/google/takeout/html.py index d393957..3ce692c 100644 --- a/my/google/takeout/html.py +++ b/my/google/takeout/html.py @@ -8,7 +8,6 @@ from pathlib import Path from datetime import datetime from html.parser import HTMLParser from typing import List, Optional, Any, Callable, Iterable, Tuple -from collections import OrderedDict from urllib.parse import unquote import pytz @@ -94,8 +93,8 @@ class TakeoutHTMLParser(HTMLParser): def handle_starttag(self, tag, attrs): if self.state == State.INSIDE and tag == 'a': self.state = State.PARSING_LINK - attrs = OrderedDict(attrs) - hr = attrs['href'] + [hr] = (v for k, v in attrs if k == 'href') + assert hr is not None # sometimes it's starts with this prefix, it's apparently clicks from google search? or visits from chrome address line? who knows... # TODO handle http? diff --git a/my/hypothesis.py b/my/hypothesis.py index 55fff64..82104cd 100644 --- a/my/hypothesis.py +++ b/my/hypothesis.py @@ -41,6 +41,7 @@ except ModuleNotFoundError as e: dal = pre_pip_dal_handler('hypexport', e, config, requires=REQUIRES) +DAL = dal.DAL Highlight = dal.Highlight Page = dal.Page @@ -49,8 +50,8 @@ def inputs() -> Sequence[Path]: return get_files(config.export_path) -def _dal() -> dal.DAL: - return dal.DAL(inputs()) +def _dal() -> DAL: + return DAL(inputs()) # TODO they are in reverse chronological order... diff --git a/my/smscalls.py b/my/smscalls.py index f436709..b56026d 100644 --- a/my/smscalls.py +++ b/my/smscalls.py @@ -24,7 +24,7 @@ from datetime import datetime, timezone from pathlib import Path from typing import NamedTuple, Iterator, Set, Tuple, Optional, Any, Dict, List -from lxml import etree +import lxml.etree as etree from my.core.error import Res