Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fast-forward cookiecutter, drop Python3.8 #154

Merged
merged 5 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 2 additions & 21 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/Ouranosinc/cookiecutter-pypackage",
"commit": "9e52dd4dcbae384ca055d1edd4aa79ec5b436ca0",
"commit": "b9dc57245a77dd3c465a444d4943884ee92157ea",
"checkout": null,
"context": {
"cookiecutter": {
Expand All @@ -22,26 +22,7 @@
"create_author_file": "y",
"open_source_license": "MIT license",
"generated_with_cruft": "y",
"__gh_slug": "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_name.replace(' ', '-') }}",
"__prompts__": {
"full_name": "Your full name",
"email": "Your email address",
"github_username": "Your GitHub username (or organization)",
"project_name": "The name of your project",
"project_short_description": "A short description of your project",
"pypi_username": "Your PyPI username (or organization)",
"version": "The version of your project",
"use_pytest": "Do you want to use pytest?",
"use_black": "Do you want to use Black for code formatting?",
"use_conda": "Do you want to add configurations for Anaconda package management?",
"add_pyup_badge": "Do you want to add a pyup.io badge? (not recommended)",
"make_docs": "Do you want to generate documentation files",
"add_translations": "Do you want to add translations?",
"command_line_interface": "Which command-line interface do you want to use?",
"create_author_file": "Do you want to create an AUTHORS.rst file?",
"open_source_license": "Which open-source license do you want to use?",
"generated_with_cruft": "Was this project generated with Cruft? (Add a '.cruft.json' file)"
},
"__gh_slug": "https://github.com/hydrologie/xdatasets",
"_template": "https://github.com/Ouranosinc/cookiecutter-pypackage"
}
},
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/first-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ jobs:
It appears that this is your first Pull Request. To give credit where it's due, we ask that you add your information to the \`AUTHORS.rst\` and \`.zenodo.json\`:
- [ ] The relevant author information has been added to \`AUTHORS.rst\` and \`.zenodo.json\`.

Please make sure you've read our [contributing guide](CONTRIBUTING.rst). We look forward to reviewing your Pull Request shortly ✨`
Please make sure you've read our [contributing guide](https://github.com/hydrologie/xdatasets/blob/main/CONTRIBUTING.rst). We look forward to reviewing your Pull Request shortly ✨`
})
20 changes: 7 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,11 @@ jobs:
ESMF_VERSION: "v8.5.0"
strategy:
matrix:
include:
- tox-env: "py38-coveralls"
python-version: "3.8"
- tox-env: "py39-coveralls"
python-version: "3.9"
- tox-env: "py310-coveralls"
python-version: "3.10"
- tox-env: "py311-coveralls"
python-version: "3.11"
- tox-env: "py312-coveralls"
python-version: "3.12"
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- name: Harden Runner
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
Expand Down Expand Up @@ -93,11 +87,11 @@ jobs:
python -m pip install --require-hashes -r CI/requirements_ci.txt
- name: Test with tox
run: |
tox -e ${{ matrix.tox-env }}
tox
env:
ESMF_VERSION: ${{ env.ESMF_VERSION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: run-${{ matrix.tox-env }}
COVERALLS_FLAG_NAME: run-${{ matrix.python-version }}
COVERALLS_PARALLEL: true
COVERALLS_SERVICE_NAME: github

Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
rev: v3.17.0
hooks:
- id: pyupgrade
args: [ '--py38-plus' ]
args: [ '--py39-plus' ]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
Expand Down Expand Up @@ -41,7 +41,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.6
rev: v0.5.7
hooks:
- id: ruff
args: [ '--fix' ]
Expand All @@ -56,17 +56,17 @@ repos:
rev: 1.8.7
hooks:
- id: nbqa-pyupgrade
args: [ '--py38-plus' ]
args: [ '--py39-plus' ]
additional_dependencies: [ 'pyupgrade==3.16.0' ]
- id: nbqa-black
additional_dependencies: [ 'black==24.4.2' ]
additional_dependencies: [ 'black==24.8.0' ]
- id: nbqa-isort
additional_dependencies: [ 'isort==5.13.2' ]
- repo: https://github.com/keewis/blackdoc
rev: v0.3.9
hooks:
- id: blackdoc
additional_dependencies: [ 'black==24.4.2' ]
additional_dependencies: [ 'black==24.8.0' ]
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
Expand All @@ -79,7 +79,7 @@ repos:
- id: yamllint
args: [ '--config-file=.yamllint.yaml' ]
- repo: https://github.com/numpy/numpydoc
rev: v1.8.0rc2
rev: v1.8.0
hooks:
- id: numpydoc-validation
exclude: ^docs/|^tests/
Expand Down
10 changes: 6 additions & 4 deletions CI/requirements_ci.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
bump-my-version
coveralls
flit
tox
bump-my-version==0.25.1
coveralls==4.0.1
flit==3.9.0
pip==24.2.0
tox==4.17.1
tox-gh==1.3.2
26 changes: 15 additions & 11 deletions CI/requirements_ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ bracex==2.4 \
--hash=sha256:a27eaf1df42cf561fed58b7a8f3fdf129d1ea16a81e1fadd1d17989bc6384beb \
--hash=sha256:efdc71eff95eaff5e0f8cfebe7d01adf2c8637c8c92edaf63ef348c241a82418
# via wcmatch
bump-my-version==0.24.3 \
--hash=sha256:9b8ac82458a703a968a9a438b460175494cc0e0c6bd5f316019945a6b66eb81f \
--hash=sha256:cdd86e158430dd5e5e25fc61703c140a1107579fdd8d74f8f3a5f991daa07168
bump-my-version==0.25.1 \
--hash=sha256:d5e72b1a88db4cc808009fd4f03c3b3ab5c06db7bf1501e4f8387eb50c352589 \
--hash=sha256:f9a2723999be5c4416c854ad4a7f950491644944dff82a91634f8a45d1da81ac
# via -r CI/requirements_ci.in
cachetools==5.3.3 \
--hash=sha256:0abad1021d3f8325b2fc1d2e9c8b9c9d57b04c3932657a72465447332c24d945 \
--hash=sha256:ba29e2dfa0b8b556606f097407ed1aa62080ee108ab0dc5ec9d6a723a007d105
cachetools==5.4.0 \
--hash=sha256:3ae3b49a3d5e28a77a0be2b37dbcb89005058959cb2323858c2657c4a8cab474 \
--hash=sha256:b8adc2e7c07f105ced7bc56dbb6dfbe7c4a00acce20e2227b3f355be89bc6827
# via tox
certifi==2024.7.4 \
--hash=sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b \
Expand Down Expand Up @@ -393,18 +393,22 @@ tomlkit==0.13.0 \
--hash=sha256:08ad192699734149f5b97b45f1f18dad7eb1b6d16bc72ad0c2335772650d7b72 \
--hash=sha256:7075d3042d03b80f603482d69bf0c8f345c2b30e41699fd8883227f89972b264
# via bump-my-version
tox==4.16.0 \
--hash=sha256:43499656f9949edb681c0f907f86fbfee98677af9919d8b11ae5ad77cb800748 \
--hash=sha256:61e101061b977b46cf00093d4319438055290ad0009f84497a07bf2d2d7a06d0
tox==4.17.1 \
--hash=sha256:2974597c0353577126ab014f52d1a399fb761049e165ff34427f84e8cfe6c990 \
--hash=sha256:2c41565a571e34480bd401d668a4899806169a4633e972ac296c54406d2ded8a
# via
# -r CI/requirements_ci.in
# tox-gh
tox-gh==1.3.2 \
--hash=sha256:beb8d277d5d7c1a1f09c107e4ef80bd7dd2f8f5d020edfaf4c1e3ae8fd45bf6f \
--hash=sha256:c2d6e977f66712e7cd5e5d1b655a1bd4c91ebaf3be104befdb53c81587292d7e
# via -r CI/requirements_ci.in
typing-extensions==4.12.2 \
--hash=sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d \
--hash=sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8
# via
# annotated-types
# pydantic
# pydantic-core
# rich
# rich-click
urllib3==2.2.2 \
--hash=sha256:a448b2f64d686155468037e1ace9f2d2199776e17f0a46610480d311f73e3472 \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ clean-test: ## remove test and coverage artifacts
lint/flake8: ## check style with flake8
python -m ruff check src/xdatasets tests
python -m flake8 --config=.flake8 src/xdatasets tests
validate-docstrings src/xdatasets/**.py
python -m numpydoc lint src/xdatasets/**.py

lint/black: ## check style with black
python -m black --check src/xdatasets tests
Expand Down
18 changes: 9 additions & 9 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ dependencies:
- xarray >=2023.1
- zarr
# Dev tools and testing
- pip >=24.0
- bump-my-version >=0.24.3
- black ==24.4.2
- pip >=24.2.0
- bump-my-version >=0.25.1
- black ==24.8.0
- blackdoc ==0.3.9
- coverage >=7.5.0
- coveralls >=4.0.0
- flake8 >=7.1.0
- coveralls >=4.0.1
- flake8 >=7.1.1
- flake8-rst-docstrings >=0.3.0
- flit >=3.9.0,<4.0
- isort ==5.13.2
- numpydoc >=1.7.0
- numpydoc >=1.8.0
- pip >=23.3.0
- pre-commit >=3.5.0
- pytest >=8.2.2
- pytest >=8.3.2
- pytest-cov >=5.0.0
- ruff >=0.5.0
- ruff >=0.5.7
- tokenize-rt >=3.2.0
- tox >=4.16.0
- tox >=4.17.1
- watchdog >=4.0.0
27 changes: 12 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ maintainers = [
{name = "Trevor James Smith", email = "[email protected]"}
]
readme = {file = "README.rst", content-type = "text/x-rst"}
requires-python = ">=3.8.0"
requires-python = ">=3.9.0"
keywords = [
"xdatasets",
"hydrology",
Expand All @@ -30,7 +30,6 @@ classifiers = [
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down Expand Up @@ -66,33 +65,33 @@ dependencies = [
[project.optional-dependencies]
dev = [
# Dev tools and testing
"black ==24.4.2",
"black ==24.8.0",
"blackdoc ==0.3.9",
"bump-my-version >=0.24.3",
"bump-my-version >=0.25.1",
"coverage >=7.5.0",
"coveralls >=4.0.0",
"flake8 >=7.1.0",
"coveralls >=4.0.1",
"flake8 >=7.1.1",
"flake8-rst-docstrings >=0.3.0",
"flit >=3.9.0,<4.0",
"ipython",
"isort ==5.13.2",
"mypy",
"nbval",
"numpydoc >=1.7.0",
"pip >=24.0",
"numpydoc >=1.8.0",
"pip >=24.2.0",
"pre-commit >=3.5.0",
"pylint",
"pytest-cov >=5.0.0",
"pytest >=8.2.2",
"ruff >=0.5.0",
"pytest >=8.3.2",
"ruff >=0.5.7",
"tokenize-rt",
"tox >=4.16.0",
"tox >=4.17.1",
"watchdog >=4.0.0",
"xdoctest"
]
docs = [
# Documentation and examples
"cartopy",
"cartopy >=0.23",
"distributed >=2.0",
"furo",
"geoviews",
Expand All @@ -105,7 +104,6 @@ docs = [
"nbsphinx",
"nc-time-axis",
"netCDF4",
"pandoc",
"panel",
"pooch",
"s3fs",
Expand Down Expand Up @@ -135,7 +133,6 @@ all = [

[tool.black]
target-version = [
"py38",
"py39",
"py310",
"py311",
Expand Down Expand Up @@ -254,7 +251,7 @@ exclude = [

[tool.isort]
profile = "black"
py_version = 38
py_version = 39

[tool.mypy]
files = "."
Expand Down
28 changes: 16 additions & 12 deletions src/xdatasets/core.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import logging.config
import warnings
from typing import Any, Callable, Dict, List, Optional, Union
from logging import getLogger
from typing import Any, Callable, List, Optional, Union

import geopandas as gpd
import intake
Expand All @@ -18,7 +18,7 @@
)

logging.config.dictConfig(LOGGING_CONFIG)
logger = logging.getLogger(__name__)
logger = getLogger(__name__)

url_path = "https://raw.githubusercontent.com/hydrocloudservices/catalogs/main/catalogs/main.yaml"

Expand Down Expand Up @@ -107,9 +107,9 @@ class Query: # numpydoc ignore=PR09

def __init__(
self,
datasets: Union[str, List[str], Dict[str, Union[str, List[str]]]],
space: Dict[str, Union[str, List[str]]] = dict(),
time: Dict[str, Union[str, List[str]]] = dict(),
datasets: Union[str, list[str], dict[str, Union[str, list[str]]]],
space: dict[str, Union[str, list[str]]] = dict(),
time: dict[str, Union[str, list[str]]] = dict(),
catalog_path: str = url_path,
) -> None:
# We cache the catalog's yaml files for easier access behind corporate firewalls
Expand All @@ -125,10 +125,10 @@ def __init__(
def _resolve_space_params(
self,
clip: Optional[str] = None,
geometry: Union[Dict[str, tuple], gpd.GeoDataFrame] = None,
geometry: Union[dict[str, tuple], gpd.GeoDataFrame] = None,
averaging: Optional[bool] = False,
unique_id: Optional[str] = None,
) -> Dict:
) -> dict:
"""
Resolve and validate user-provided space params.

Expand Down Expand Up @@ -168,13 +168,13 @@ def _resolve_time_params(
self,
timestep: Optional[str] = None,
aggregation: Optional[
Dict[str, Union[Callable[..., Any], List[Callable[..., Any]]]]
dict[str, Union[Callable[..., Any], list[Callable[..., Any]]]]
] = None,
start: Optional[bool] = None,
end: Optional[str] = None,
timezone: Optional[str] = None,
minimum_duration: Optional[str] = None,
) -> Dict:
) -> dict:
"""
Resolve and validate user-provided time params.

Expand Down Expand Up @@ -220,8 +220,8 @@ def _resolve_time_params(

def load_query(
self,
datasets: Union[str, Dict[str, Union[str, List[str]]]],
space: Dict[str, Union[str, List[str]]],
datasets: Union[str, dict[str, Union[str, list[str]]]],
space: dict[str, Union[str, list[str]]],
time,
):
# Get all datasets in query
Expand All @@ -230,6 +230,10 @@ def load_query(

elif isinstance(datasets, dict):
datasets_name = list(datasets.keys())
else:
raise ValueError(
"Datasets should be a string, a list of strings, or a dictionary."
)

# Load data for each dataset
dsets = []
Expand Down
Loading
Loading