diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 1034a745..abecc9dd 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -11,13 +11,16 @@ on: jobs: python-tests: runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8, 3.12] steps: - name: "Checkout branch" uses: actions/checkout@v4 - name: "Set up Python on Ubuntu" - uses: actions/setup-python@v5 + uses: actions/setup-python@v2 with: - python-version: 3.12 + python-version: ${{ matrix.python-version }} - name: "Python codestyle" run: | pip install ".[dev]" diff --git a/src/ipyaladin/__init__.py b/src/ipyaladin/__init__.py index b968c5dc..67a9499e 100644 --- a/src/ipyaladin/__init__.py +++ b/src/ipyaladin/__init__.py @@ -1,5 +1,6 @@ import importlib.metadata import pathlib +import typing from typing import ClassVar, Union, Final, Optional import warnings @@ -7,13 +8,12 @@ from astropy.table.table import QTable from astropy.table import Table from astropy.coordinates import SkyCoord, Angle +import traitlets from traitlets import ( Float, Int, Unicode, Bool, - List, - Dict, Any, default, ) @@ -86,21 +86,21 @@ class Aladin(anywidget.AnyWidget): show_coo_grid_control = Bool(True).tag(sync=True, init_option=True) grid_color = Unicode("rgb(178, 50, 178)").tag(sync=True, init_option=True) grid_opacity = Float(0.5).tag(sync=True, init_option=True) - grid_options = Dict().tag(sync=True, init_option=True) + grid_options = traitlets.Dict().tag(sync=True, init_option=True) # content of the last click - clicked_object = Dict().tag(sync=True) + clicked_object = traitlets.Dict().tag(sync=True) # listener callback is on the python side and contains functions to link to events - listener_callback: ClassVar[dict[str, callable]] = {} + listener_callback: ClassVar[typing.Dict[str, callable]] = {} # overlay survey overlay_survey = Unicode("").tag(sync=True, init_option=True) overlay_survey_opacity = Float(0.0).tag(sync=True, init_option=True) - init_options = List(trait=Any()).tag(sync=True) + init_options = traitlets.List(trait=Any()).tag(sync=True) @default("init_options") - def _init_options(self) -> list[str]: + def _init_options(self) -> typing.List[str]: return list(self.traits(init_option=True)) def __init__(self, *args: any, **kwargs: any) -> None: diff --git a/src/ipyaladin/coordinate_parser.py b/src/ipyaladin/coordinate_parser.py index 5dd3dc2a..a23e1ce3 100644 --- a/src/ipyaladin/coordinate_parser.py +++ b/src/ipyaladin/coordinate_parser.py @@ -1,3 +1,5 @@ +from typing import Tuple + from astropy.coordinates import SkyCoord, Angle import re @@ -18,7 +20,7 @@ def parse_coordinate_string(string: str) -> SkyCoord: """ if not _is_coordinate_string(string): return SkyCoord.from_name(string) - coordinates: tuple[str, str] = _split_coordinate_string(string) + coordinates: Tuple[str, str] = _split_coordinate_string(string) # Parse ra and dec to astropy Angle objects dec: Angle = Angle(coordinates[1], unit="deg") if _is_hour_angle_string(coordinates[0]): @@ -51,7 +53,7 @@ def _is_coordinate_string(string: str) -> bool: return bool(re.match(regex, string)) -def _split_coordinate_string(coo: str) -> tuple[str, str]: +def _split_coordinate_string(coo: str) -> Tuple[str, str]: """Split a string containing coordinates in two parts. Parameters diff --git a/src/test/test_coordinate_parser.py b/src/test/test_coordinate_parser.py index 7f2c317e..b399bc4a 100644 --- a/src/test/test_coordinate_parser.py +++ b/src/test/test_coordinate_parser.py @@ -1,3 +1,4 @@ +from typing import Tuple from ipyaladin.coordinate_parser import ( parse_coordinate_string, _split_coordinate_string, @@ -67,7 +68,7 @@ def test_is_coordinate_string(inp: str, expected: bool) -> None: @pytest.mark.parametrize(("inp", "expected"), test_split_coordinate_string_values) -def test_split_coordinate_string(inp: str, expected: tuple[str, str]) -> None: +def test_split_coordinate_string(inp: str, expected: Tuple[str, str]) -> None: """Test the function _split_coordinate_string. Parameters