Skip to content

Commit

Permalink
Merge pull request #82 from questionlp/develop
Browse files Browse the repository at this point in the history
Migrate from black to ruff, fix location join, add postal abbreviations retrieval function, format code
  • Loading branch information
questionlp authored Jan 30, 2025
2 parents 7580357 + 8c2bc32 commit 43e116e
Show file tree
Hide file tree
Showing 61 changed files with 309 additions and 211 deletions.
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
"source.fixAll": "explicit",
"source.sortImports": "explicit",
},
"editor.defaultFormatter": "ms-python.black-formatter"
}
}
16 changes: 16 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
Changes
*******

2.15.0
======

Application Changes
-------------------

* Change SQL joins from ``JOIN`` to ``LEFT JOIN`` in :py:class:`wwdtm.location.Location` to properly handle ``NULL`` values in the ``state`` column
* Add :py:meth:`wwdtm.location.Location.retrieve_postal_abbreviations` that returns postal abbreviations and their corresponding names and countries

Development Changes
-------------------

* Upgrade ruff from 0.7.0 to 0.9.3
* Remove black from required development packages as part of migrating entirely to Ruff
* Ran ```ruff format``` to format Python code files using the Ruff 2025 Style Guide

2.14.0
======

Expand Down
9 changes: 3 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ version = {attr = "wwdtm.VERSION"}
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.black]
required-version = "24.10.0"
target-version = ["py310", "py311", "py312", "py313"]
line-length = 88

[tool.pytest.ini_options]
minversion = "8.3"
filterwarnings = [
Expand All @@ -60,6 +55,7 @@ norecursedirs = [
]

[tool.ruff]
required-version = ">= 0.9.0"
target-version = "py310"

exclude = [
Expand All @@ -73,7 +69,7 @@ exclude = [
".venv",
]

line-length = 88 # Must agree with Black
line-length = 88

[tool.ruff.lint]
ignore = [
Expand All @@ -93,6 +89,7 @@ ignore = [
"F401",
"TRY003", # Avoid specifying messages outside exception class; overly strict, especially for ValueError
"S608",
"ISC001",
]

select = [
Expand Down
3 changes: 1 addition & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ruff==0.7.0
black==24.10.0
ruff==0.9.3
pytest==8.3.3
pytest-cov==5.0.0
wheel==0.44.0
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# vim: set noai syntax=python ts=4 sw=4:
"""Deprecated: Package setup file."""

from setuptools import setup

setup()
1 change: 1 addition & 0 deletions tests/guest/test_guest_appearances.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# vim: set noai syntax=python ts=4 sw=4:
"""Testing for object: :py:class:`wwdtm.guest.GuestAppearances`."""

import json
from pathlib import Path
from typing import Any
Expand Down
13 changes: 7 additions & 6 deletions tests/guest/test_guest_guest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# vim: set noai syntax=python ts=4 sw=4:
"""Testing for object: :py:class:`wwdtm.guest.Guest`."""

import json
from pathlib import Path
from typing import Any
Expand Down Expand Up @@ -43,9 +44,9 @@ def test_guest_retrieve_all_details():

assert guests, "No guests could be retrieved"
assert "id" in guests[0], "'id' was not returned for first list item"
assert (
"appearances" in guests[0]
), "'appearances' was not returned for the first list item"
assert "appearances" in guests[0], (
"'appearances' was not returned for the first list item"
)


def test_guest_retrieve_all_ids():
Expand Down Expand Up @@ -116,6 +117,6 @@ def test_guest_guest_retrieve_details_by_slug(guest_slug: str):

assert info, f"Guest slug {guest_slug} not found"
assert "name" in info, f"'name' was not returned for slug {guest_slug}"
assert (
"appearances" in info
), f"'appearances' was not returned for slug {guest_slug}"
assert "appearances" in info, (
f"'appearances' was not returned for slug {guest_slug}"
)
1 change: 1 addition & 0 deletions tests/guest/test_guest_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# vim: set noai syntax=python ts=4 sw=4:
"""Testing for object: :py:class:`wdtm.guest.GuestUtility`."""

import json
from pathlib import Path
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions tests/host/test_host_appearances.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# vim: set noai syntax=python ts=4 sw=4:
"""Testing for object: :py:class:`wwdtm.host.HostAppearances`."""

import json
from pathlib import Path
from typing import Any
Expand Down
7 changes: 4 additions & 3 deletions tests/host/test_host_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# vim: set noai syntax=python ts=4 sw=4:
"""Testing for object: :py:class:`wwdtm.host.Host`."""

import json
from pathlib import Path
from typing import Any
Expand Down Expand Up @@ -49,9 +50,9 @@ def test_host_retrieve_all_details():
assert "name" in hosts[0], "'name' was not returned for the first list item"
assert "slug" in hosts[0], "'slug' was not returned for the first list item"
assert "pronouns" in hosts[0], "'pronouns' was not returned for the first list item"
assert (
"appearances" in hosts[0]
), "'appearances' was not returned for thefirst list item"
assert "appearances" in hosts[0], (
"'appearances' was not returned for thefirst list item"
)


def test_host_retrieve_all_ids():
Expand Down
1 change: 1 addition & 0 deletions tests/host/test_host_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# vim: set noai syntax=python ts=4 sw=4:
"""Testing for object: :py:class:`wwdtm.host.HostUtility`."""

import json
from pathlib import Path
from typing import Any
Expand Down
17 changes: 15 additions & 2 deletions tests/location/test_location_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# vim: set noai syntax=python ts=4 sw=4:
"""Testing for object: :py:class:`wwdtm.location.Location`."""

import json
from pathlib import Path
from typing import Any
Expand Down Expand Up @@ -86,7 +87,7 @@ def test_location_retrieve_all_slugs():
assert slugs, "No location slug strings could be retrieved"


@pytest.mark.parametrize("location_id", [95])
@pytest.mark.parametrize("location_id", [95, 148])
def test_location_retrieve_by_id(location_id: int):
"""Testing for :py:meth:`wwdtm.location.Location.retrieve_by_id`.
Expand All @@ -108,7 +109,7 @@ def test_location_retrieve_by_id(location_id: int):
), f"'longitude' was not returned for ID {location_id}"


@pytest.mark.parametrize("location_id", [95])
@pytest.mark.parametrize("location_id", [95, 148])
def test_location_retrieve_details_by_id(location_id: int):
"""Testing for :py:meth:`wwdtm.location.location.retrieve_details_by_id`.
Expand Down Expand Up @@ -179,3 +180,15 @@ def test_location_retrieve_details_by_slug(location_slug: str):
assert (
"recordings" in info
), f"'recordings' was not returned for slug {location_slug}"


def test_location_retrieve_postal_abbreviations():
"""Testing for :py:meth:`wwdtm.location.Location.retrieve_postal_abbreviations`."""
location = Location(connect_dict=get_connect_dict())
abbreviations = location.retrieve_postal_abbreviations()

assert abbreviations, "Postal abbreviations not returned"
assert "OR" in abbreviations, "Postal abbreviation 'OR' not found"
assert (
"name" in abbreviations["OR"]
), "Postal abbreviation 'OR' does not contain a valid name"
1 change: 1 addition & 0 deletions tests/location/test_location_recordings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# vim: set noai syntax=python ts=4 sw=4:
"""Testing for object: :py:class:`wwdtm.location.LocationRecordings`."""

import json
from pathlib import Path
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions tests/location/test_location_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# vim: set noai syntax=python ts=4 sw=4:
"""Testing for object: :py:class:`wwdtm.location.LocationUtility`."""

import json
from pathlib import Path
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions tests/panelist/test_panelist_appearances.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# vim: set noai syntax=python ts=4 sw=4:
"""Testing for object: :py:class:`wwdtm.panelist.PanelistAppearances`."""

import json
from pathlib import Path
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions tests/panelist/test_panelist_decimal_scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# vim: set noai syntax=python ts=4 sw=4:
"""Testing for object: :py:class:`wwdtm.panelist.PanelistDecimalScores`."""

import json
from pathlib import Path
from typing import Any
Expand Down
25 changes: 13 additions & 12 deletions tests/panelist/test_panelist_panelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# vim: set noai syntax=python ts=4 sw=4:
"""Testing for object: :py:class:`wwdtm.panelist.Panelist`."""

import json
from pathlib import Path
from typing import Any
Expand Down Expand Up @@ -36,9 +37,9 @@ def test_panelist_retrieve_all():
assert "id" in panelists[0], "'id' was not returned for the first list item"
assert "name" in panelists[0], "'name' was not returned for the first list item"
assert "slug" in panelists[0], "'slug' was not returned for the first list item"
assert (
"pronouns" in panelists[0]
), "'pronouns' was not returned for the first list item"
assert "pronouns" in panelists[0], (
"'pronouns' was not returned for the first list item"
)


@pytest.mark.parametrize("use_decimal_scores", [True, False])
Expand All @@ -55,12 +56,12 @@ def test_panelist_retrieve_all_details(use_decimal_scores: bool):
assert "id" in panelists[0], "'id' was not returned for first list item"
assert "name" in panelists[0], "'name' was not returned for the first list item"
assert "slug" in panelists[0], "'slug' was not returned for the first list item"
assert (
"pronouns" in panelists[0]
), "'pronouns' was not returned for the first list item"
assert (
"appearances" in panelists[0]
), "'appearances' was not returned for the first list item"
assert "pronouns" in panelists[0], (
"'pronouns' was not returned for the first list item"
)
assert "appearances" in panelists[0], (
"'appearances' was not returned for the first list item"
)


def test_panelist_retrieve_all_ids():
Expand Down Expand Up @@ -154,6 +155,6 @@ def test_panelist_retrieve_details_by_slug(
assert "name" in info, f"'name' was not returned for slug {panelist_slug}"
assert "slug" in info, f"'slug' was not returned for ID {panelist_slug}"
assert "pronouns" in info, f"'pronouns' was not returned for ID {panelist_slug}"
assert (
"appearances" in info
), f"'appearances' was not returned for slug {panelist_slug}"
assert "appearances" in info, (
f"'appearances' was not returned for slug {panelist_slug}"
)
1 change: 1 addition & 0 deletions tests/panelist/test_panelist_scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# vim: set noai syntax=python ts=4 sw=4:
"""Testing for object: :py:class:`wwdtm.panelist.PanelistScores`."""

import json
from pathlib import Path
from typing import Any
Expand Down
13 changes: 7 additions & 6 deletions tests/panelist/test_panelist_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# vim: set noai syntax=python ts=4 sw=4:
"""Testing for object: :py:class:`wwdtm.panelist.PanelistStatistics`."""

import json
from pathlib import Path
from typing import Any
Expand Down Expand Up @@ -101,9 +102,9 @@ def test_panelist_statistics_retrieve_statistics_by_id(

assert "scoring" in stats, f"'scoring' was not returned for ID {panelist_id}"
if include_decimal_scores:
assert (
"scoring_decimal" in stats
), f"'scoring' was not returned for ID {panelist_id}"
assert "scoring_decimal" in stats, (
f"'scoring' was not returned for ID {panelist_id}"
)
assert "ranking" in stats, f"'ranking' was not returned for ID {panelist_id}"


Expand All @@ -128,7 +129,7 @@ def test_panelist_statistics_retrieve_statistics_by_slug(

assert "scoring" in stats, f"'scoring' was not returned for slug {panelist_slug}"
if include_decimal_scores:
assert (
"scoring_decimal" in stats
), f"'scoring' was not returned for ID {panelist_slug}"
assert "scoring_decimal" in stats, (
f"'scoring' was not returned for ID {panelist_slug}"
)
assert "ranking" in stats, f"'ranking' was not returned for slug {panelist_slug}"
1 change: 1 addition & 0 deletions tests/panelist/test_panelist_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# vim: set noai syntax=python ts=4 sw=4:
"""Testing for object: :py:class:`wwdtm.panelist.PanelistUtility`."""

import json
from pathlib import Path
from typing import Any
Expand Down
7 changes: 4 additions & 3 deletions tests/pronoun/test_pronoun_pronouns.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# vim: set noai syntax=python ts=4 sw=4:
"""Testing for object: :py:class:`wwdtm.pronoun.Pronouns`."""

import json
from pathlib import Path
from typing import Any
Expand Down Expand Up @@ -34,9 +35,9 @@ def test_pronouns_retrieve_all():

assert all_pronouns, "No pronouns could be retrieved"
assert "id" in all_pronouns[0], "'id' was not returned for the first list item"
assert (
"pronouns" in all_pronouns[0]
), "'pronouns' was not returned for the first list item"
assert "pronouns" in all_pronouns[0], (
"'pronouns' was not returned for the first list item"
)


def test_pronouns_retrieve_all_ids():
Expand Down
13 changes: 7 additions & 6 deletions tests/scorekeeper/test_scorekeeper_appearances.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# vim: set noai syntax=python ts=4 sw=4:
"""Testing for object: :py:class:`wwdtm.scorekeeper.ScorekeeperAppearances`."""

import json
from pathlib import Path
from typing import Any
Expand Down Expand Up @@ -51,9 +52,9 @@ def test_scorekeeper_appearance_retrieve_appearances_by_slug(scorekeeper_slug: s
appearances = ScorekeeperAppearances(connect_dict=get_connect_dict())
appearance = appearances.retrieve_appearances_by_slug(scorekeeper_slug)

assert (
"count" in appearance
), f"'count' was not returned for slug {scorekeeper_slug}"
assert (
"shows" in appearance
), f"'shows' was not returned for slug {scorekeeper_slug}"
assert "count" in appearance, (
f"'count' was not returned for slug {scorekeeper_slug}"
)
assert "shows" in appearance, (
f"'shows' was not returned for slug {scorekeeper_slug}"
)
Loading

0 comments on commit 43e116e

Please sign in to comment.