forked from pydata/xarray
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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) ...
- Loading branch information
Showing
89 changed files
with
2,039 additions
and
550 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ref-names: $Format:%D$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# reduce the number of merge conflicts | ||
doc/whats-new.rst merge=union | ||
# allow installing from git archives | ||
.git_archival.txt export-subst |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: "pre-commit autoupdate CI" | ||
|
||
on: | ||
schedule: | ||
- cron: "0 0 * * 0" # every Sunday at 00:00 UTC | ||
workflow_dispatch: | ||
|
||
|
||
jobs: | ||
autoupdate: | ||
name: 'pre-commit autoupdate' | ||
runs-on: ubuntu-latest | ||
if: github.repository == 'pydata/xarray' | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v2 | ||
- name: Cache pip and pre-commit | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cache/pre-commit | ||
~/.cache/pip | ||
key: ${{ runner.os }}-pre-commit-autoupdate | ||
- name: setup python | ||
uses: actions/setup-python@v2 | ||
- name: upgrade pip | ||
run: python -m pip install --upgrade pip | ||
- name: install dependencies | ||
run: python -m pip install --upgrade pre-commit pyyaml packaging | ||
- name: version info | ||
run: python -m pip list | ||
- name: autoupdate | ||
uses: technote-space/create-pr-action@837dbe469b39f08d416889369a52e2a993625c84 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
EXECUTE_COMMANDS: | | ||
python -m pre_commit autoupdate | ||
python .github/workflows/sync_linter_versions.py .pre-commit-config.yaml ci/requirements/mypy_only | ||
COMMIT_MESSAGE: 'pre-commit: autoupdate hook versions' | ||
COMMIT_NAME: 'github-actions[bot]' | ||
COMMIT_EMAIL: 'github-actions[bot]@users.noreply.github.com' | ||
PR_TITLE: 'pre-commit: autoupdate hook versions' | ||
PR_BRANCH_PREFIX: 'pre-commit/' | ||
PR_BRANCH_NAME: 'autoupdate-${PR_ID}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env python | ||
import argparse | ||
import itertools | ||
import pathlib | ||
import re | ||
|
||
import yaml | ||
from packaging import version | ||
from packaging.requirements import Requirement | ||
|
||
operator_re = re.compile("=+") | ||
|
||
|
||
def extract_versions(config): | ||
repos = config.get("repos") | ||
if repos is None: | ||
raise ValueError("invalid pre-commit configuration") | ||
|
||
extracted_versions = ( | ||
((hook["id"], version.parse(repo["rev"])) for hook in repo["hooks"]) | ||
for repo in repos | ||
) | ||
return dict(itertools.chain.from_iterable(extracted_versions)) | ||
|
||
|
||
def update_requirement(line, new_versions): | ||
# convert to pep-508 compatible | ||
preprocessed = operator_re.sub("==", line) | ||
requirement = Requirement(preprocessed) | ||
|
||
specifier, *_ = requirement.specifier | ||
old_version = specifier.version | ||
new_version = new_versions.get(requirement.name, old_version) | ||
|
||
new_line = f"{requirement.name}={new_version}" | ||
|
||
return new_line | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--dry", action="store_true") | ||
parser.add_argument( | ||
metavar="pre-commit-config", dest="pre_commit_config", type=pathlib.Path | ||
) | ||
parser.add_argument("requirements", type=pathlib.Path) | ||
args = parser.parse_args() | ||
|
||
with args.pre_commit_config.open() as f: | ||
config = yaml.safe_load(f) | ||
|
||
versions = extract_versions(config) | ||
mypy_version = versions["mypy"] | ||
|
||
requirements_text = args.requirements.read_text() | ||
requirements = requirements_text.split("\n") | ||
new_requirements = [ | ||
update_requirement(line, versions) | ||
if line and not line.startswith("# ") | ||
else line | ||
for line in requirements | ||
] | ||
new_requirements_text = "\n".join(new_requirements) | ||
|
||
if args.dry: | ||
separator = "\n" + "—" * 80 + "\n" | ||
print( | ||
"contents of the old requirements file:", | ||
requirements_text, | ||
"contents of the new requirements file:", | ||
new_requirements_text, | ||
sep=separator, | ||
end=separator, | ||
) | ||
else: | ||
args.requirements.write_text(new_requirements_text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.