Skip to content

Commit 8714281

Browse files
committed
refactor: unify settings and build to pyproject.toml
1 parent dea55ae commit 8714281

23 files changed

+289
-308
lines changed

.dockerignore

-2
This file was deleted.

.editorconfig

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ root = true
66

77

88
[*]
9-
109
# Change these settings to your own preference
1110
indent_style = space
1211
indent_size = 4
@@ -19,3 +18,6 @@ insert_final_newline = true
1918

2019
[*.md]
2120
trim_trailing_whitespace = false
21+
22+
[*.yml]
23+
indent_size = 2

.github/workflows/ci.yaml

-39
This file was deleted.

.github/workflows/ci.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: ci
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: [3.8]
11+
steps:
12+
- name: Check out code
13+
uses: actions/checkout@v3
14+
- name: Set up Python ${{ matrix.python-version }}
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: ${{ matrix.python-version }}
18+
cache: "pip"
19+
- name: Install Dependencies
20+
run: |
21+
python -m venv venv
22+
source venv/bin/activate
23+
pip install -e ".[dev]"
24+
- name: Check Formatting
25+
run: |
26+
source venv/bin/activate
27+
inv lint-black
28+
- name: Check Linting
29+
run: |
30+
source venv/bin/activate
31+
inv lint-pylint
32+
- name: Check Types
33+
run: |
34+
source venv/bin/activate
35+
inv lint-mypy
36+
- name: Test
37+
run: |
38+
source venv/bin/activate
39+
inv test

.github/workflows/release_helper.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ jobs:
104104
base: dev
105105
title: "chore: sync main->dev"
106106
labels: chore
107-
# reviewers:
107+
# reviewers:
108108
assignees: melange396
109109
body: |
110110
Syncing Main->Dev.

.gitignore

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
.mypy_cache
22
*.pyc
33
__pycache__
4-
/venv
5-
/docs/_build
64
.coverage
75
.pytest_cache
6+
.DS_Store
87
*.egg-info
9-
/dist
10-
.DS_Store
8+
dist/
9+
build/
10+
docs/_build
11+
venv/

.pre-commit-config.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.5.1
5+
hooks:
6+
# Run the linter.
7+
- id: ruff
8+
args: [--fix]
9+
# Run the formatter.
10+
- id: ruff-format

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ Install with the following commands:
1212
# Latest dev version
1313
pip install -e "git+https://github.com/cmu-delphi/epidatpy.git#egg=epidatpy"
1414

15-
# PyPI version
15+
# PyPI version (not yet available)
1616
pip install epidatpy
1717
```
1818

1919
## Usage
2020

2121
TODO
2222

23-
## Development Environment
23+
## Development
2424

2525
Prepare virtual environment and install dependencies
2626

2727
```sh
2828
python -m venv venv
2929
source ./venv/bin/activate
30-
pip install --use-feature=2020-resolver -r requirements.txt -r requirements-dev.txt
30+
pip install -e ".[dev]"
3131
```
3232

3333
### Common Commands
@@ -44,7 +44,7 @@ inv dist # build distribution packages
4444
inv release # upload the current version to pypi
4545
```
4646

47-
## Release Process
47+
### Release Process
4848

4949
The release consists of multiple steps which can be all done via the GitHub website:
5050

epidatpy/__init__.py

+41-16
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,52 @@
11
"""Fetch data from Delphi's API."""
22

3+
# Make the linter happy about the unused variables
4+
__all__ = [
5+
"get_api_key",
6+
"__version__",
7+
"CovidcastDataSources",
8+
"DataSignal",
9+
"DataSignalGeoStatistics",
10+
"DataSource",
11+
"GeoType",
12+
"TimeType",
13+
"WebLink",
14+
"AEpiDataEndpoints",
15+
"AEpiDataCall",
16+
"EpiDataFormatType",
17+
"EpiDataResponse",
18+
"EpiRange",
19+
"EpiRangeDict",
20+
"EpiRangeLike",
21+
"EpiRangeParam",
22+
"IntParam",
23+
"InvalidArgumentException",
24+
"StringParam",
25+
]
26+
__author__ = "Delphi Research Group"
27+
28+
29+
from ._auth import get_api_key
330
from ._constants import __version__
31+
from ._covidcast import (
32+
CovidcastDataSources,
33+
DataSignal,
34+
DataSignalGeoStatistics,
35+
DataSource,
36+
GeoType,
37+
TimeType,
38+
WebLink,
39+
)
40+
from ._endpoints import AEpiDataEndpoints
441
from ._model import (
42+
AEpiDataCall,
43+
EpiDataFormatType,
44+
EpiDataResponse,
545
EpiRange,
646
EpiRangeDict,
7-
EpiDataResponse,
847
EpiRangeLike,
9-
InvalidArgumentException,
1048
EpiRangeParam,
1149
IntParam,
50+
InvalidArgumentException,
1251
StringParam,
13-
EpiDataFormatType,
14-
AEpiDataCall,
1552
)
16-
from ._covidcast import (
17-
DataSignal,
18-
DataSource,
19-
WebLink,
20-
DataSignalGeoStatistics,
21-
CovidcastDataSources,
22-
GeoType,
23-
TimeType,
24-
)
25-
from ._auth import get_api_key
26-
27-
__author__ = "Delphi Group"

epidatpy/_constants.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import Final
22

3-
43
__version__: Final = "0.5.0"
54
HTTP_HEADERS: Final = {"User-Agent": f"epidatpy/{__version__}"}
65
BASE_URL: Final = "https://api.delphi.cmu.edu/epidata/"

epidatpy/_covidcast.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from dataclasses import Field, InitVar, dataclass, field, fields
2+
from functools import cached_property
23
from typing import (
34
Any,
45
Callable,
@@ -13,21 +14,21 @@
1314
Sequence,
1415
Tuple,
1516
Union,
16-
overload,
1717
get_args,
18+
overload,
1819
)
19-
from functools import cached_property
20+
2021
from pandas import DataFrame
22+
2123
from ._model import (
22-
EpiRangeLike,
2324
CALL_TYPE,
2425
EpidataFieldInfo,
2526
EpidataFieldType,
27+
EpiRangeLike,
2628
EpiRangeParam,
2729
InvalidArgumentException,
2830
)
2931

30-
3132
GeoType = Literal["nation", "msa", "hrr", "hhs", "state", "county"]
3233
TimeType = Literal["day", "week"]
3334

@@ -119,11 +120,13 @@ class DataSignal(Generic[CALL_TYPE]):
119120
geo_types: Dict[GeoType, DataSignalGeoStatistics] = field(default_factory=dict)
120121

121122
def __post_init__(self) -> None:
122-
self.link = [WebLink(alt=l["alt"], href=l["href"]) if isinstance(l, dict) else l for l in self.link]
123+
self.link = [
124+
WebLink(alt=link["alt"], href=link["href"]) if isinstance(link, dict) else link for link in self.link
125+
]
123126
stats_fields = fields(DataSignalGeoStatistics)
124127
self.geo_types = {
125-
k: DataSignalGeoStatistics(**_limit_fields(l, stats_fields)) if isinstance(l, dict) else l
126-
for k, l in self.geo_types.items()
128+
k: DataSignalGeoStatistics(**_limit_fields(v, stats_fields)) if isinstance(v, dict) else v
129+
for k, v in self.geo_types.items()
127130
}
128131

129132
@staticmethod
@@ -222,7 +225,9 @@ def __post_init__(
222225
self,
223226
_create_call: Callable[[Mapping[str, Union[None, EpiRangeLike, Iterable[EpiRangeLike]]]], CALL_TYPE],
224227
) -> None:
225-
self.link = [WebLink(alt=l["alt"], href=l["href"]) if isinstance(l, dict) else l for l in self.link]
228+
self.link = [
229+
WebLink(alt=link["alt"], href=link["href"]) if isinstance(link, dict) else link for link in self.link
230+
]
226231
signal_fields = fields(DataSignal)
227232
self.signals = [
228233
DataSignal(_create_call=_create_call, **_limit_fields(s, signal_fields)) if isinstance(s, dict) else s

0 commit comments

Comments
 (0)