Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
john-kurkowski committed Mar 14, 2022
1 parent 286188c commit d3298bb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
def test_bad_kwargs():
with pytest.raises(ValueError):
tldextract.TLDExtract(
cache_dir=False, suffix_list_urls=False, fallback_to_snapshot=False
cache_dir=None, suffix_list_urls=(), fallback_to_snapshot=False
)
4 changes: 2 additions & 2 deletions tests/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,10 @@ def test_cache_timeouts(tmpdir):

def test_tlds_property():
extract_private = tldextract.TLDExtract(
cache_dir=None, suffix_list_urls=None, include_psl_private_domains=True
cache_dir=None, suffix_list_urls=(), include_psl_private_domains=True
)
extract_public = tldextract.TLDExtract(
cache_dir=None, suffix_list_urls=None, include_psl_private_domains=False
cache_dir=None, suffix_list_urls=(), include_psl_private_domains=False
)
assert len(extract_private.tlds) > len(extract_public.tlds)

Expand Down
6 changes: 3 additions & 3 deletions tests/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import os.path
import sys
import types
from typing import Any, cast

import pytest
import tldextract.cache
from tldextract.cache import (DiskCache, get_cache_dir,
get_pkg_unique_identifier)
from tldextract.cache import DiskCache, get_cache_dir, get_pkg_unique_identifier


def test_disk_cache(tmpdir):
Expand All @@ -28,7 +28,7 @@ def test_get_pkg_unique_identifier(monkeypatch):
monkeypatch.setattr(sys, "prefix", "/home/john/.pyenv/versions/myvirtualenv")

mock_version_module = types.ModuleType("tldextract._version", "mocked module")
mock_version_module.version = "1.2.3"
cast(Any, mock_version_module).version = "1.2.3"
monkeypatch.setitem(sys.modules, "tldextract._version", mock_version_module)

assert (
Expand Down
3 changes: 2 additions & 1 deletion tldextract/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ def _fetch_url(session, url, timeout):
def _make_cache_key(inputs):
key = repr(inputs)
try:
key = md5(key).hexdigest()
# TODO: does this path ever not throw?
key = md5(key).hexdigest() # type: ignore[arg-type]
except TypeError:
key = md5(key.encode("utf8")).hexdigest()
return key
Expand Down

0 comments on commit d3298bb

Please sign in to comment.