Skip to content

Commit

Permalink
refactor: hardcopy abstract attribute to drop better_abc requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
martibosch committed Oct 9, 2024
1 parent ab58652 commit c0d3b4b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
9 changes: 4 additions & 5 deletions meteora/clients/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import pyproj
import requests
import requests_cache
from better_abc import abstract_attribute
from pyogrio.errors import DataSourceError
from shapely import geometry
from shapely.geometry.base import BaseGeometry
Expand Down Expand Up @@ -86,17 +85,17 @@ def __init__(self, *args, **kwargs):
session = requests.Session()
self._session = session

@abstract_attribute
@utils.abstract_attribute
def X_COL(self): # pylint: disable=invalid-name
"""Name of the column with longitude coordinates."""
pass

@abstract_attribute
@utils.abstract_attribute
def Y_COL(self): # pylint: disable=invalid-name
"""Name of the column with latitude coordinates."""
pass

@abstract_attribute
@utils.abstract_attribute
def CRS(self) -> pyproj.CRS: # pylint: disable=invalid-name
"""CRS of the data source."""
pass
Expand Down Expand Up @@ -325,7 +324,7 @@ def _get_content_from_url(

return response_content

@abstract_attribute
@utils.abstract_attribute
def _ts_endpoint(self):
pass

Expand Down
2 changes: 1 addition & 1 deletion meteora/mixins/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from abc import ABC, abstractmethod

from better_abc import abstract_attribute
from meteora.utils import abstract_attribute


class APIKeyMixin(ABC):
Expand Down
3 changes: 2 additions & 1 deletion meteora/mixins/stations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import geopandas as gpd
import pandas as pd
from better_abc import abstract_attribute

from meteora.utils import abstract_attribute


class StationsEndpointMixin(ABC):
Expand Down
3 changes: 2 additions & 1 deletion meteora/mixins/variables.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Variables mixins."""

import pandas as pd
from better_abc import abstract_attribute

from meteora.utils import abstract_attribute

# https://public.wmo.int/en/programmes/global-climate-observing-system/essential-climate-variables
ECVS = [
Expand Down
17 changes: 17 additions & 0 deletions meteora/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@
from meteora import settings


# `DummyAttribute` and `abstract_attribute` below are hardcoded from
# github.com/rykener/better-abc to avoid relying on an unmaintained library that is not
# in conda-forge
class DummyAttribute:
"""Dummy attribute."""

pass


def abstract_attribute(obj=None):
"""Abstract attribute."""
if obj is None:
obj = DummyAttribute()
obj.__is_abstract_attribute__ = True
return obj


def dms_to_decimal(ser: pd.Series) -> pd.Series:
"""Convert a series from degrees, minutes, seconds (DMS) to decimal degrees."""
degrees = ser.str[0:2].astype(int)
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ classifiers = [
"Programming Language :: Python :: 3.12",
]
dependencies = [
"better-abc",
"geopandas>=1.0.0",
"matplotlib",
"requests",
Expand Down

0 comments on commit c0d3b4b

Please sign in to comment.