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

Revamp CI #102

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
69 changes: 69 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[tool.black]
line-length = 100
target-version = ['py39']
skip-string-normalization = true


[build-system]
requires = [
"setuptools>=61",
"setuptools-scm"
]
build-backend = "setuptools.build_meta"


[project]
name = "xarray-schema"
description = "Schema validation for Xarray objects"
readme = "README.md"
license = {text = "MIT"}
authors = [{name = "Xarray-schema Developers", email = "[email protected]"}]
requires-python = ">=3.8"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
requires-python = ">=3.8"
requires-python = ">=3.9"

let's drop 3.8 as part of this PR

classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Intended Audience :: Science/Research",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Scientific/Engineering",
]
dynamic = ["version"]
dependencies = [
"xarray>=0.16"
]
[project.optional-dependencies]

dev = [
"jsonschema",
"pytest",
"pytest-cov",
"mypy==0.982",
"types-jsonschema",
"types-setuptools==65.5.0.3"
]
[project.urls]
documentation = "https://xarray-schema.readthedocs.io/"
repository = "https://github.com/xarray-contrib/xarray-schema"

[tool.setuptools.packages.find]
include = ["xarray_schema*"]

[tool.setuptools_scm]
version_scheme = "post-release"
local_scheme = "dirty-tag"
fallback_version = "999"


[tool.pytest.ini_options]
log_cli = true
log_level = "INFO"

[tool.mypy]
allow_redefinition = true
exclude = "properties|asv_bench|doc|tests|flycheck"
files = "xarray_schema/*.py"
show_error_codes = true
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: weekly
interval: monthly
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every weekday
interval: weekly
interval: monthly
4 changes: 0 additions & 4 deletions .mypy.ini

This file was deleted.

27 changes: 18 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
ci:
autoupdate_schedule: monthly

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-json
- id: check-yaml
- id: double-quote-string-fixer
- id: mixed-line-ending

- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
hooks:
- id: pyupgrade
args:
- "--py39-plus"

- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
args: ["--line-length", "100", "--skip-string-normalization"]
- id: black-jupyter

- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
hooks:
- id: blackdoc

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
Expand All @@ -32,4 +42,3 @@ repos:
rev: v3.0.0-alpha.4
hooks:
- id: prettier
language_version: system
30 changes: 15 additions & 15 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

# -- Project information -----------------------------------------------------

project = 'xarray-schema'
copyright = '2022, CarbonPlan'
author = 'CarbonPlan'
project = "xarray-schema"
copyright = "2022, CarbonPlan"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
copyright = "2022, CarbonPlan"
copyright = "2023, CarbonPlan"

author = "CarbonPlan"


# -- General configuration ---------------------------------------------------
Expand All @@ -28,35 +28,35 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx_rtd_theme',
'sphinx.ext.autosummary',
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx_autodoc_typehints',
'IPython.sphinxext.ipython_directive',
'IPython.sphinxext.ipython_console_highlighting',
'nbsphinx',
"sphinx_rtd_theme",
"sphinx.ext.autosummary",
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx_autodoc_typehints",
"IPython.sphinxext.ipython_directive",
"IPython.sphinxext.ipython_console_highlighting",
"nbsphinx",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
# html_static_path = ['_static']

autodoc_default_options = {'exclude-members': '__init__'}
autodoc_default_options = {"exclude-members": "__init__"}
18 changes: 10 additions & 8 deletions docs/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"metadata": {},
"outputs": [],
"source": [
"da = xr.DataArray(np.ones((4, 10), dtype='i4'), dims=['x', 't'], name='foo')"
"da = xr.DataArray(np.ones((4, 10), dtype=\"i4\"), dims=[\"x\", \"t\"], name=\"foo\")"
]
},
{
Expand All @@ -58,7 +58,7 @@
"metadata": {},
"outputs": [],
"source": [
"schema = DataArraySchema(dtype=np.integer, name='foo', shape=(4, None))"
"schema = DataArraySchema(dtype=np.integer, name=\"foo\", shape=(4, None))"
]
},
{
Expand Down Expand Up @@ -108,7 +108,7 @@
}
],
"source": [
"da2 = xr.DataArray(np.ones((4, 10), dtype='f4'), dims=['x', 't'], name='foo')\n",
"da2 = xr.DataArray(np.ones((4, 10), dtype=\"f4\"), dims=[\"x\", \"t\"], name=\"foo\")\n",
"schema.validate(da2)"
]
},
Expand Down Expand Up @@ -174,15 +174,17 @@
" ChunksSchema,\n",
" ArrayTypeSchema,\n",
" AttrSchema,\n",
" AttrsSchema\n",
" AttrsSchema,\n",
")\n",
"\n",
"# example constructions\n",
"dtype_schema = DTypeSchema('i4')\n",
"dims_schema = DimsSchema(('x', 'y', None)) # None is used as a wildcard\n",
"dtype_schema = DTypeSchema(\"i4\")\n",
"dims_schema = DimsSchema((\"x\", \"y\", None)) # None is used as a wildcard\n",
"shape_schema = ShapeSchema((5, 10, None)) # None is used as a wildcard\n",
"name_schema = NameSchema('foo')\n",
"chunk_schema = ChunksSchema({'x': None, 'y': -1}) # None is used as a wildcard, -1 is used as\n",
"name_schema = NameSchema(\"foo\")\n",
"chunk_schema = ChunksSchema(\n",
" {\"x\": None, \"y\": -1}\n",
") # None is used as a wildcard, -1 is used as\n",
"ArrayTypeSchema = ArrayTypeSchema(np.ndarray)\n",
"\n",
"# Example usage\n",
Expand Down
18 changes: 1 addition & 17 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,8 @@ max-complexity = 18
select = B,C,E,F,W,T4,B9

[isort]
known_first_party=xarray_schema
known_third_party=dask,invoke,jsonschema,numpy,pkg_resources,pytest,setuptools,xarray
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
combine_as_imports=True
line_length=100
skip=
docs/source/conf.py
setup.py
profile=black

[tool:pytest]
log_cli = True
log_level = INFO

[coverage:run]
omit =
tasks.py

[mypy]
plugins = numpy.typing.mypy_plugin
49 changes: 2 additions & 47 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,49 +1,4 @@
#!/usr/bin/env python
from setuptools import setup

"""The setup script."""

from os.path import exists

from setuptools import find_packages, setup

with open('requirements.txt') as f:
install_requires = f.read().strip().split('\n')

if exists('README.md'):
with open('README.md') as f:
long_description = f.read()
else:
long_description = ''

CLASSIFIERS = [
'Development Status :: 3 - Alpha',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Intended Audience :: Science/Research',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Topic :: Scientific/Engineering',
]

setup(
name='xarray-schema',
description='Schema validation for Xarray objects',
long_description=long_description,
long_description_content_type='text/markdown',
python_requires='>=3.8',
maintainer='Joe Hamman',
maintainer_email='[email protected]',
classifiers=CLASSIFIERS,
url='https://github.com/xarray-contrib/xarray-schema',
packages=find_packages(exclude=('tests',)),
package_dir={'xarray_schema': 'xarray_schema'},
include_package_data=True,
install_requires=install_requires,
license='MIT',
zip_safe=False,
keywords=['xarray', 'schema'],
use_scm_version={'version_scheme': 'post-release', 'local_scheme': 'dirty-tag'},
setup_requires=['setuptools_scm', 'setuptools>=30.3.0'],
)
setup(use_scm_version={"fallback_version": "999"})
6 changes: 3 additions & 3 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from invoke import task # pragma: no cover

SRC_DIR = 'xarray_schema' # pragma: no cover
TEST_DIR = 'tests' # pragma: no cover
SRC_DIR = "xarray_schema" # pragma: no cover
TEST_DIR = "tests" # pragma: no cover


@task # pragma: no cover
def mypy(c): # pragma: no cover
c.run(f'mypy {SRC_DIR} {TEST_DIR}') # pragma: no cover
c.run(f"mypy {SRC_DIR} {TEST_DIR}") # pragma: no cover
Loading