diff --git a/.github/workflows/build_workflow.yml b/.github/workflows/build_workflow.yml index a62120b0..73391e1c 100644 --- a/.github/workflows/build_workflow.yml +++ b/.github/workflows/build_workflow.yml @@ -50,7 +50,7 @@ jobs: shell: bash -l {0} strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.9", "3.10", "3.11"] steps: - id: skip_check uses: fkirc/skip-duplicate-actions@master @@ -98,7 +98,10 @@ jobs: - if: $${{ steps.skip_check.outputs.should_skip != 'true' || steps.cache.outputs.cache-hit != 'true' }} name: Update environment - run: mamba env update -n xcdat_ci -f conda-env/ci.yml + run: | + mamba env update -n xcdat_ci -f conda-env/ci.yml + # Make sure the Python version in the env matches the current matrix version. + mamba install -c conda-forge python=${{ matrix.python-version }} - if: ${{ steps.skip_check.outputs.should_skip != 'true' }} name: Install xcdat diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cddf2200..ca94815a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: - id: check-yaml - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 23.3.0 hooks: - id: black @@ -30,15 +30,15 @@ repos: additional_dependencies: [flake8-isort] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.1.1 + rev: v1.4.0 hooks: - id: mypy - args: ["--config=setup.cfg"] + args: ["--config=pyproject.toml"] additional_dependencies: [ - dask==2023.3.2, - numpy==1.23.5, - pandas==1.5.3, - xarray==2023.3.0, - types-python-dateutil==2.8.19, + dask, + numpy>=1.23.0, + pandas, + xarray>=2023.2.0, + types-python-dateutil, ] diff --git a/.readthedocs.yml b/.readthedocs.yml index c33dee3f..3be49e8e 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -6,9 +6,9 @@ version: 2 build: - os: "ubuntu-20.04" - tools: - python: "mambaforge-4.10" + os: "ubuntu-20.04" + tools: + python: "mambaforge-4.10" # Build documentation in the docs/ directory with Sphinx sphinx: @@ -19,4 +19,4 @@ formats: - pdf conda: - environment: conda-env/readthedocs.yml + environment: conda-env/dev.yml diff --git a/conda-env/ci.yml b/conda-env/ci.yml index 61c71c84..4551fdcb 100644 --- a/conda-env/ci.yml +++ b/conda-env/ci.yml @@ -1,28 +1,25 @@ -# Conda xcdat CI/CD environment (used in GH Actions) +# Conda xcdat CI/CD environment (used in GH Actions). name: xcdat_ci channels: - conda-forge - defaults dependencies: - # ================== - # Base - # ================== - - python >=3.8 - - pip + # Base - required for building the package. + # ========================================= + - python >=3.9 - cf_xarray - cftime - dask - - esmpy - lxml - netcdf4 - - numpy + - numpy >=1.23.0 # This version of numpy includes support for Python 3.11. - pandas - python-dateutil - - xarray - # Constrained because 0.6.3 breaks with import ESMF - # Source: https://github.com/pangeo-data/xESMF/issues/212 - - xesmf >0.6.3 + - xarray >=2022.02.0 # This version of Xarray drops support for Python 3.9. - xgcm + # Optional - enables additional features. + # ========================================= + - xesmf >=0.7.0 # Constrained because https://github.com/pangeo-data/xESMF/issues/212. # Quality Assurance # ================== - types-python-dateutil diff --git a/conda-env/dev.yml b/conda-env/dev.yml index c09b316f..fa86cc2c 100644 --- a/conda-env/dev.yml +++ b/conda-env/dev.yml @@ -4,29 +4,24 @@ channels: - conda-forge - defaults dependencies: - # ================== - # Base - # ================== - # NOTE: If versions are updated, also `additional_dependencies` list for mypy in `.pre-commit-config.yaml` - - python=3.10.10 - - pip=23.0.1 - - cf_xarray=0.8.0 - - cftime=1.6.2 - - dask=2023.3.2 - - lxml=4.9.2 - - netcdf4=1.6.3 - - numpy=1.23.5 - - pandas=1.5.3 - - python-dateutil=2.8.2 - - xarray=2023.4.2 - - xgcm=0.8.0 - # ================== - # Optional - # ================== - - xesmf=0.7.0 - - matplotlib-base=3.7.1 + # Base - required for building the package. + # ========================================= + - python >=3.9 + - cf_xarray + - cftime + - dask + - lxml + - netcdf4 + - numpy >=1.23.0 # This version of numpy includes support for Python 3.11. + - pandas + - python-dateutil + - xarray >=2022.02.0 # This version of Xarray drops support for Python 3.9. + - xgcm + # Optional - enables additional features. + # ========================================= + - xesmf >=0.7.0 # Constrained because https://github.com/pangeo-data/xESMF/issues/212. + - matplotlib-base >=3.7.0 - nc-time-axis=1.4.1 - # ================== # Documentation # ================== - sphinx=5.3.0 @@ -37,25 +32,22 @@ dependencies: - pandoc=3.1.1 - ipython=8.11.0 # Required for nbsphinx syntax highlighting - gsw-xarray=0.3.0 # Required for vertical regridding example - # ================== # Quality Assurance # ================== - # NOTE: If versions are updated, also update 'rev' in `.pre-commit.config.yaml` - - black=23.1.0 + - types-python-dateutil + # NOTE: If the tools below are updated, also update their 'rev' in `.pre-commit.config.yaml` + - black=23.3.0 - flake8=6.0.0 - flake8-isort=6.0.0 - isort=5.12.0 - - mypy=1.1.1 + - mypy=1.4.0 - pre-commit=3.2.0 - - types-python-dateutil=2.8.19 - # ================== # Testing # ================== - - pytest=7.2.2 - - pytest-cov=4.0.0 - # ================== + - pytest + - pytest-cov # Developer Tools # ================== - - jupyterlab=3.6.2 - - tbump=6.9.0 + - jupyterlab + - tbump prefix: /opt/miniconda3/envs/xcdat_dev diff --git a/conda-env/readthedocs.yml b/conda-env/readthedocs.yml deleted file mode 100644 index 17bdcb5e..00000000 --- a/conda-env/readthedocs.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: xcdat_rtd -channels: - - conda-forge - - defaults -dependencies: - # ================== - # Base - # ================== - # NOTE: If versions are updated, also `additional_dependencies` list for mypy in `.pre-commit-config.yaml` - - python=3.10.10 - - pip=23.0.1 - - cf_xarray=0.8.0 - - cftime=1.6.2 - - dask=2023.3.2 - - lxml=4.9.2 - - netcdf4=1.6.3 - - numpy=1.23.5 - - pandas=1.5.3 - - python-dateutil=2.8.2 - - xarray=2023.4.2 - - xgcm=0.8.0 - # ================== - # Optional - # ================== - - xesmf=0.7.0 - - matplotlib-base=3.7.1 - - nc-time-axis=1.4.1 - # ================== - # Documentation - # ================== - - sphinx=5.3.0 - - sphinx-autosummary-accessors=2022.4.0 - - sphinx-book-theme=1.0.1 - - sphinx-copybutton=0.5.1 - - nbsphinx=0.9.1 - - pandoc=3.1.1 - - ipython=8.11.0 # Required for nbsphinx syntax highlighting - # Quality Assurance - # ================== - - types-python-dateutil=2.8.19 -prefix: /opt/miniconda3/envs/xcdat_rtd diff --git a/pyproject.toml b/pyproject.toml index 7c50f1a5..116e2f52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,3 +21,28 @@ exclude = ''' )/ ) ''' + +[tool.isort] +# Docs: https://pycqa.github.io/isort/docs/configuration/options.html#example-pyprojecttoml_4 +multi_line_output = 3 +include_trailing_comma = true +force_grid_wrap = 0 +use_parentheses = true +line_length = 88 + +[tool.pytest.ini_options] +# Docs: https://docs.pytest.org/en/7.2.x/reference/customize.html#configuration +junit_family = "xunit2" +addopts = "--cov=xcdat --cov-report term --cov-report html:tests_coverage_reports/htmlcov --cov-report xml:tests_coverage_reports/coverage.xml -s" +python_files = ["tests.py", "test_*.py"] +# These markers are defined in `xarray.tests` and must be included to avoid warnings when importing from this module. +markers = ["flaky", "network"] + +[tool.mypy] +# Docs: https://mypy.readthedocs.io/en/stable/config_file.html +python_version = 3.10 +check_untyped_defs = true +ignore_missing_imports = true +warn_unused_ignores = true +warn_redundant_casts = true +warn_unused_configs = true diff --git a/setup.cfg b/setup.cfg index 0c10dbed..c7cd0b32 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,6 @@ [flake8] # https://pep8.readthedocs.io/en/latest/intro.html#error-codes +# flake8 dooes not support pyproject.toml yet: https://github.com/PyCQA/flake8/issues/234 ignore = # whitespace before ‘:’ E203 @@ -23,45 +24,6 @@ exclude = *__init__.py venv -[isort] -multi_line_output=3 -include_trailing_comma=True -force_grid_wrap=0 -use_parentheses=True -line_length=88 - -[pycodestyle] -max-line-length = 119 -exclude = - .tox - .git - */migrations/* - */static/CACHE/* - docs - node_modules - .idea - .mypy_cache - .pytest_cache - *__init__.py - venv - -[mypy] -python_version = 3.10 -check_untyped_defs = True -ignore_missing_imports = True -warn_unused_ignores = True -warn_redundant_casts = True -warn_unused_configs = True - [aliases] # Define setup.py command aliases here test = pytest - -[tool:pytest] -junit_family=xunit2 -addopts = --cov=xcdat --cov-report term --cov-report html:tests_coverage_reports/htmlcov --cov-report xml:tests_coverage_reports/coverage.xml -s -python_files = tests.py test_*.py -# These markers are defined in `xarray.tests` and must be included to avoid warnings when importing from this module. -markers = - flaky - network