Skip to content

Commit 3f04332

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix/4107
* upstream/master: (46 commits) pin netCDF4=1.5.3 in min-all-deps (pydata#4982) fix matplotlib errors for single level discrete colormaps (pydata#4256) Adapt exception handling in CFTimeIndex.__sub__ and __rsub__ (pydata#5006) Update options.py (pydata#5000) Adjust tests to use updated pandas syntax for offsets (pydata#4537) add a combine_attrs parameter to Dataset.merge (pydata#4895) Support for dask.graph_manipulation (pydata#4965) raise on passing axis to Dataset.reduce methods (pydata#4940) Whatsnew for 0.17.1 (pydata#4963) Refinements to how-to-release (pydata#4964) DOC: add example for reindex (pydata#4956) DOC: rm np import (pydata#4949) Add 0.17.0 release notes (pydata#4953) document update as inplace (pydata#4932) bump the dependencies (pydata#4942) Upstream CI: limit runtime (pydata#4946) typing for numpy 1.20 (pydata#4878) Use definition of DTypeLike from Numpy if found (pydata#4941) autoupdate mypy (pydata#4943) Add DataArrayCoarsen.reduce and DatasetCoarsen.reduce methods (pydata#4939) ...
2 parents fc9be4e + 7905c51 commit 3f04332

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+2039
-550
lines changed

.git_archival.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ref-names: $Format:%D$

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# reduce the number of merge conflicts
22
doc/whats-new.rst merge=union
3+
# allow installing from git archives
4+
.git_archival.txt export-subst

.github/actions/detect-ci-trigger/action.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/actions/detect-ci-trigger/script.sh

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/ci-additional.yaml

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v2
2020
with:
2121
fetch-depth: 2
22-
- uses: ./.github/actions/detect-ci-trigger
22+
- uses: xarray-contrib/ci-trigger@v1
2323
id: detect-trigger
2424
with:
2525
keyword: "[skip-ci]"
@@ -157,6 +157,50 @@ jobs:
157157
run: |
158158
python -m pytest --doctest-modules xarray --ignore xarray/tests
159159
160+
typing:
161+
name: Type checking (mypy)
162+
runs-on: "ubuntu-latest"
163+
needs: detect-ci-trigger
164+
if: needs.detect-ci-trigger.outputs.triggered == 'false'
165+
defaults:
166+
run:
167+
shell: bash -l {0}
168+
169+
steps:
170+
- name: Cancel previous runs
171+
uses: styfle/[email protected]
172+
with:
173+
access_token: ${{ github.token }}
174+
- uses: actions/checkout@v2
175+
with:
176+
fetch-depth: 0 # Fetch all history for all branches and tags.
177+
- uses: conda-incubator/setup-miniconda@v2
178+
with:
179+
channels: conda-forge
180+
channel-priority: strict
181+
mamba-version: "*"
182+
activate-environment: xarray-tests
183+
auto-update-conda: false
184+
python-version: "3.8"
185+
186+
- name: Install conda dependencies
187+
run: |
188+
mamba env update -f ci/requirements/environment.yml
189+
- name: Install mypy
190+
run: |
191+
mamba install --file ci/requirements/mypy_only
192+
- name: Install xarray
193+
run: |
194+
python -m pip install --no-deps -e .
195+
- name: Version info
196+
run: |
197+
conda info -a
198+
conda list
199+
python xarray/util/print_versions.py
200+
- name: Run mypy
201+
run: |
202+
python -m mypy xarray
203+
160204
min-version-policy:
161205
name: Minimum Version Policy
162206
runs-on: "ubuntu-latest"
@@ -184,6 +228,6 @@ jobs:
184228

185229
- name: minimum versions policy
186230
run: |
187-
mamba install -y pyyaml conda
231+
mamba install -y pyyaml conda python-dateutil
188232
python ci/min_deps_check.py ci/requirements/py37-bare-minimum.yml
189233
python ci/min_deps_check.py ci/requirements/py37-min-all-deps.yml
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: "pre-commit autoupdate CI"
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * 0" # every Sunday at 00:00 UTC
6+
workflow_dispatch:
7+
8+
9+
jobs:
10+
autoupdate:
11+
name: 'pre-commit autoupdate'
12+
runs-on: ubuntu-latest
13+
if: github.repository == 'pydata/xarray'
14+
steps:
15+
- name: checkout
16+
uses: actions/checkout@v2
17+
- name: Cache pip and pre-commit
18+
uses: actions/cache@v2
19+
with:
20+
path: |
21+
~/.cache/pre-commit
22+
~/.cache/pip
23+
key: ${{ runner.os }}-pre-commit-autoupdate
24+
- name: setup python
25+
uses: actions/setup-python@v2
26+
- name: upgrade pip
27+
run: python -m pip install --upgrade pip
28+
- name: install dependencies
29+
run: python -m pip install --upgrade pre-commit pyyaml packaging
30+
- name: version info
31+
run: python -m pip list
32+
- name: autoupdate
33+
uses: technote-space/create-pr-action@837dbe469b39f08d416889369a52e2a993625c84
34+
with:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
EXECUTE_COMMANDS: |
37+
python -m pre_commit autoupdate
38+
python .github/workflows/sync_linter_versions.py .pre-commit-config.yaml ci/requirements/mypy_only
39+
COMMIT_MESSAGE: 'pre-commit: autoupdate hook versions'
40+
COMMIT_NAME: 'github-actions[bot]'
41+
COMMIT_EMAIL: 'github-actions[bot]@users.noreply.github.com'
42+
PR_TITLE: 'pre-commit: autoupdate hook versions'
43+
PR_BRANCH_PREFIX: 'pre-commit/'
44+
PR_BRANCH_NAME: 'autoupdate-${PR_ID}'

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v2
2020
with:
2121
fetch-depth: 2
22-
- uses: ./.github/actions/detect-ci-trigger
22+
- uses: xarray-contrib/ci-trigger@v1
2323
id: detect-trigger
2424
with:
2525
keyword: "[skip-ci]"

.github/workflows/parse_logs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def extract_short_test_summary_info(lines):
1818
)
1919
up_to_section_content = itertools.islice(up_to_start_of_section, 1, None)
2020
section_content = itertools.takewhile(
21-
lambda l: l.startswith("FAILED"), up_to_section_content
21+
lambda l: l.startswith("FAILED") or l.startswith("ERROR"), up_to_section_content
2222
)
2323
content = "\n".join(section_content)
2424

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env python
2+
import argparse
3+
import itertools
4+
import pathlib
5+
import re
6+
7+
import yaml
8+
from packaging import version
9+
from packaging.requirements import Requirement
10+
11+
operator_re = re.compile("=+")
12+
13+
14+
def extract_versions(config):
15+
repos = config.get("repos")
16+
if repos is None:
17+
raise ValueError("invalid pre-commit configuration")
18+
19+
extracted_versions = (
20+
((hook["id"], version.parse(repo["rev"])) for hook in repo["hooks"])
21+
for repo in repos
22+
)
23+
return dict(itertools.chain.from_iterable(extracted_versions))
24+
25+
26+
def update_requirement(line, new_versions):
27+
# convert to pep-508 compatible
28+
preprocessed = operator_re.sub("==", line)
29+
requirement = Requirement(preprocessed)
30+
31+
specifier, *_ = requirement.specifier
32+
old_version = specifier.version
33+
new_version = new_versions.get(requirement.name, old_version)
34+
35+
new_line = f"{requirement.name}={new_version}"
36+
37+
return new_line
38+
39+
40+
if __name__ == "__main__":
41+
parser = argparse.ArgumentParser()
42+
parser.add_argument("--dry", action="store_true")
43+
parser.add_argument(
44+
metavar="pre-commit-config", dest="pre_commit_config", type=pathlib.Path
45+
)
46+
parser.add_argument("requirements", type=pathlib.Path)
47+
args = parser.parse_args()
48+
49+
with args.pre_commit_config.open() as f:
50+
config = yaml.safe_load(f)
51+
52+
versions = extract_versions(config)
53+
mypy_version = versions["mypy"]
54+
55+
requirements_text = args.requirements.read_text()
56+
requirements = requirements_text.split("\n")
57+
new_requirements = [
58+
update_requirement(line, versions)
59+
if line and not line.startswith("# ")
60+
else line
61+
for line in requirements
62+
]
63+
new_requirements_text = "\n".join(new_requirements)
64+
65+
if args.dry:
66+
separator = "\n" + "—" * 80 + "\n"
67+
print(
68+
"contents of the old requirements file:",
69+
requirements_text,
70+
"contents of the new requirements file:",
71+
new_requirements_text,
72+
sep=separator,
73+
end=separator,
74+
)
75+
else:
76+
args.requirements.write_text(new_requirements_text)

.github/workflows/upstream-dev-ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- uses: actions/checkout@v2
2222
with:
2323
fetch-depth: 2
24-
- uses: ./.github/actions/detect-ci-trigger
24+
- uses: xarray-contrib/ci-trigger@v1
2525
id: detect-trigger
2626
with:
2727
keyword: "[test-upstream]"
@@ -77,7 +77,7 @@ jobs:
7777
id: status
7878
run: |
7979
set -euo pipefail
80-
python -m pytest -rf | tee output-${{ matrix.python-version }}-log || (
80+
python -m pytest --timeout=60 -rf | tee output-${{ matrix.python-version }}-log || (
8181
echo '::set-output name=ARTIFACTS_AVAILABLE::true' && false
8282
)
8383
- name: Upload artifacts

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ repos:
3030
# - id: velin
3131
# args: ["--write", "--compact"]
3232
- repo: https://github.com/pre-commit/mirrors-mypy
33-
rev: v0.800
33+
# version must correspond to the one in .github/workflows/ci-additional.yaml
34+
rev: v0.812
3435
hooks:
3536
- id: mypy
3637
exclude: "properties|asv_bench"

0 commit comments

Comments
 (0)