From 1396391fbb58c7b4fbdc90e776c85fd3414ef451 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Sun, 20 Oct 2024 19:38:14 +0200 Subject: [PATCH] Code quality --- socials_util/__init__.py | 4 +++- test/test_extension.py | 14 +++++++------- test/test_parsing.py | 6 +++--- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/socials_util/__init__.py b/socials_util/__init__.py index 75b3a8e..4c472fc 100644 --- a/socials_util/__init__.py +++ b/socials_util/__init__.py @@ -12,7 +12,9 @@ from dataclasses import dataclass import aenum from enforce_typing import enforce_types -from socials_util._version import __version__ # noqa: F401 +from socials_util._version import __version__ + +__all__ = ['__version__', 'SocialSiteId', 'SocialLink', 'WikidataInfo', 'AGGERAGOR_SOCIALS', 'determine_social_from_url'] class SocialSiteId(aenum.Enum): diff --git a/test/test_extension.py b/test/test_extension.py index 349a647..7b769d1 100644 --- a/test/test_extension.py +++ b/test/test_extension.py @@ -1,17 +1,17 @@ import aenum -from socials_util import * +import socials_util def test_extension(): - MY_SECRET_SITE = aenum.extend_enum(SocialSiteId, 'MY_SECRET_SITE', 666) - assert MY_SECRET_SITE - assert SocialSiteId.MY_SECRET_SITE + my_secret_site = aenum.extend_enum(socials_util.SocialSiteId, 'MY_SECRET_SITE', 666) + assert my_secret_site + assert socials_util.SocialSiteId.MY_SECRET_SITE - REGEXES.append((r'test(\d+)', MY_SECRET_SITE)) + socials_util.REGEXES.append((r'test(\d+)', my_secret_site)) url = 'test123' - result = determine_social_from_url(url) + result = socials_util.determine_social_from_url(url) assert result is not None - assert result.social_site_id == MY_SECRET_SITE + assert result.social_site_id == my_secret_site assert result.social_id == '123' diff --git a/test/test_parsing.py b/test/test_parsing.py index a8962bf..978a367 100644 --- a/test/test_parsing.py +++ b/test/test_parsing.py @@ -198,10 +198,10 @@ NOT_PARSABLE = [ @pytest.mark.parametrize( - 'url,expected_social_site_id,expected_social_id', + ('url','expected_social_site_id','expected_social_id'), PARSABLE_SOCIAL_IDS_COMBINED, ) -def test_parse_social_ids(url, expected_social_site_id, expected_social_id): +def test_parse_social_ids(url: str, expected_social_site_id: SocialSiteId, expected_social_id: str) -> None: social_link: SocialLink | None = determine_social_from_url(url) assert social_link is not None, url assert (social_link.social_id, social_link.social_site_id) == ( @@ -211,5 +211,5 @@ def test_parse_social_ids(url, expected_social_site_id, expected_social_id): @pytest.mark.parametrize('url', NOT_PARSABLE) -def test_not_parsable(url: str): +def test_not_parsable(url: str) -> None: assert determine_social_from_url(url) is None