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

Use the latest skpkg .pre-commit-config.yml #1242

Closed
wants to merge 2 commits into from
Closed
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
34 changes: 26 additions & 8 deletions .github/ISSUE_TEMPLATE/release_checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,41 @@ labels: "release"
assignees: ""
---

### Release checklist for GitHub contributors
### PyPI/GitHub rc-release preparation checklist:

- [ ] All PRs/issues attached to the release are merged.
- [ ] All the badges on the README are passing.
- [ ] License information is verified as correct. If you are unsure, please comment below.
- [ ] Locally rendered documentation contains all appropriate pages, including API references (check no modules are
missing), tutorials, and other human written text is up-to-date with any changes in the code.
- [ ] Installation instructions in the README, documentation and on the website (e.g., diffpy.org) updated.
- [ ] Successfully run any tutorial examples or do functional testing with the latest Python version
- [ ] Grammar and writing quality have been checked (no typos).
missing), tutorials, and other human-written text is up-to-date with any changes in the code.
- [ ] Installation instructions in the README, documentation, and the website (e.g., diffpy.org) are updated.
- [ ] Successfully run any tutorial examples or do functional testing with the latest Python version.
- [ ] Grammar and writing quality are checked (no typos).
- [ ] Install `pip install build twine`, run `python -m build` and `twine check dist/*` to ensure that the package can be built and is correctly formatted for PyPI release.

Please mention @sbillinge when you are ready for release. Include any additional comments necessary, such as
version information and details about the pre-release here:
Please mention @sbillinge here when you are ready for PyPI/GitHub release. Include any additional comments necessary, such as version information and details about the pre-release here:

### PyPI/GitHub full-release preparation checklist:

- [ ] Create a new conda environment and install the rc from PyPI (`pip install <package-name>==??`)
- [ ] License information on PyPI is correct.
- [ ] Docs are deployed successfully to `https://www.diffpy.org/<package-name>`.
- [ ] Successfully run all tests, tutorial examples or do functional testing.

Please let @sbillinge know that all checks are done and the package is ready for full release.

### conda-forge release preparation checklist:

<!-- After @sbillinge releases the PyPI package, please check the following when creating a PR for conda-forge release.-->

- [ ] Ensure that the full release has appeared on PyPI successfully.
- [ ] New package dependencies listed in `conda.txt` and `test.txt` are added to `meta.yaml` in the feedstock.
- [ ] Close any open issues on the feedstock. Reach out to @bobleesj if you have questions.
- [ ] Tag @sbillinge and @bobleesj for conda-forge release.

### Post-release checklist

Before closing this issue, please complete the following:
<!-- Before closing this issue, please complete the following: -->

- [ ] Run tutorial examples and conduct functional testing using the installation guide in the README.
- [ ] Documentation (README, tutorials, API references, and websites) is deployed without broken links or missing figures.
40 changes: 28 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
default_language_version:
python: python3
python: python3
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit hooks
autofix_prs: true
autoupdate_branch: 'pre-commit-autoupdate'
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: monthly
skip: [no-commit-to-branch]
submodules: false
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit hooks
autofix_prs: true
autoupdate_branch: "pre-commit-autoupdate"
autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate"
autoupdate_schedule: monthly
skip: [no-commit-to-branch]
submodules: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
Expand Down Expand Up @@ -46,9 +46,25 @@ repos:
name: Prevent Commit to Main Branch
args: ["--branch", "main"]
stages: [pre-commit]
# codespell - spell checker for source code
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies:
- tomli
- id: codespell
additional_dependencies:
- tomli
# prettier - multi formatter for json, yaml, md
- repo: https://github.com/pre-commit/mirrors-prettier
rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8
hooks:
- id: prettier
exclude: '.*\.(html|json|css|js|yml|yaml|md)$'
additional_dependencies:
- "prettier@^3.2.4"
# docformatter - formats docstrings using PEP 257
- repo: https://github.com/s-weigand/docformatter
rev: 5757c5190d95e5449f102ace83df92e7d3b06c6c
hooks:
- id: docformatter
additional_dependencies: [tomli]
args: [--in-place, --config, ./pyproject.toml]
24 changes: 24 additions & 0 deletions news/doc-format.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
**Added:**

* 'prettier' and 'docformatter' added to .pre-commit-configs.yml
* PyPI/Github full-release nd conda-forge release checklist added.

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
10 changes: 5 additions & 5 deletions src/regolith/broker.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""API for accessing the metadata and file storage"""
"""API for accessing the metadata and file storage."""

import copy

Expand All @@ -8,15 +8,15 @@


def load_db(rc_file="regolithrc.json"):
"""Create a Broker instance from an rc file"""
"""Create a Broker instance from an rc file."""
rc = copy.copy(DEFAULT_RC)
rc._update(load_rcfile(rc_file))
filter_databases(rc)
return Broker(rc)


class Broker:
"""Interface to the database and file storage systems
"""Interface to the database and file storage systems.

Examples
--------
Expand Down Expand Up @@ -63,12 +63,12 @@ def add_file(self, document, name, filepath):

@classmethod
def from_rc(cls, rc_file="regolithrc.json"):
"""Return a Broker instance"""
"""Return a Broker instance."""
return load_db(rc_file)

def get_file_path(self, document, name):
"""Get a file from the file storage associated with the document and
name
name.

Parameters
----------
Expand Down
6 changes: 3 additions & 3 deletions src/regolith/builders/activitylogbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@


class ActivitylogBuilder(LatexBuilderBase):
"""Build CV from database entries"""
"""Build CV from database entries."""

btype = "annual-activity"
needed_colls = [
Expand All @@ -54,7 +54,7 @@ class ActivitylogBuilder(LatexBuilderBase):
]

def construct_global_ctx(self):
"""Constructs the global context"""
"""Constructs the global context."""
super().construct_global_ctx()
gtx = self.gtx
rc = self.rc
Expand All @@ -80,7 +80,7 @@ def construct_global_ctx(self):
gtx["zip"] = zip

def latex(self):
"""Render latex template"""
"""Render latex template."""
rc = self.rc
group = fuzzy_retrieval(self.gtx["groups"], ["_id", "aka", "name"], rc.groupname)
if not rc.people:
Expand Down
6 changes: 3 additions & 3 deletions src/regolith/builders/appraisalbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@


class AppraisalBuilder(LatexBuilderBase):
"""Build CV from database entries"""
"""Build CV from database entries."""

btype = "annual-activity"
needed_colls = [
Expand All @@ -45,7 +45,7 @@ class AppraisalBuilder(LatexBuilderBase):
]

def construct_global_ctx(self):
"""Constructs the global context"""
"""Constructs the global context."""
super().construct_global_ctx()
gtx = self.gtx
rc = self.rc
Expand All @@ -66,7 +66,7 @@ def construct_global_ctx(self):
gtx["zip"] = zip

def latex(self):
"""Render latex template"""
"""Render latex template."""
rc = self.rc
if not rc.people:
raise RuntimeError("ERROR: please rerun specifying --people name")
Expand Down
16 changes: 8 additions & 8 deletions src/regolith/builders/basebuilder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Builder Base Classes"""
"""Builder Base Classes."""

import os
from glob import glob
Expand All @@ -20,7 +20,7 @@


class BuilderBase(object):
"""Base class for builders"""
"""Base class for builders."""

def __init__(self, rc):
self.rc = rc
Expand All @@ -43,7 +43,7 @@ def __init__(self, rc):
self.cmds = []

def construct_global_ctx(self):
"""Constructs the global context"""
"""Constructs the global context."""
gtx = self.gtx
gtx["len"] = len
gtx["True"] = True
Expand All @@ -60,7 +60,7 @@ def construct_global_ctx(self):
gtx["date_to_rfc822"] = date_to_rfc822

def render(self, tname, fname, **kwargs):
"""Render the template into a file using the kwargs and global context
"""Render the template into a file using the kwargs and global context.

Parameters
----------
Expand Down Expand Up @@ -90,7 +90,7 @@ def build(self):


class LatexBuilderBase(BuilderBase):
"""Base class for Latex builders"""
"""Base class for Latex builders."""

def __init__(self, rc):
super().__init__(rc)
Expand All @@ -107,11 +107,11 @@ def construct_global_ctx(self):
gtx["latex_safe_url"] = latex_safe_url

def run(self, cmd):
"""Run command in build dir"""
"""Run command in build dir."""
subprocess.run(cmd, cwd=self.bldir, check=True)

def pdf(self, base):
"""Compiles latex files to PDF"""
"""Compiles latex files to PDF."""
if self.rc.pdf:
if os.name == "nt":
self.run(["pdflatex"] + LATEX_OPTS + [base + ".tex"])
Expand All @@ -120,7 +120,7 @@ def pdf(self, base):
self.run(["dvipdf", base])

def clean(self):
"""Remove files created by latex"""
"""Remove files created by latex."""
postfixes = [
"*.dvi",
"*.toc",
Expand Down
13 changes: 5 additions & 8 deletions src/regolith/builders/beamplanbuilder.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""Builder for the planning of beamtimes.

The plan contains a summary of the information for the experiments
in during a beamtime and details about how to carry out the experiments.

The plan contains a summary of the information for the experiments in
during a beamtime and details about how to carry out the experiments.
"""

from datetime import datetime
Expand All @@ -14,8 +13,7 @@


class BeamPlanBuilder(LatexBuilderBase):
"""
Build a file of experiment plans for the beamtime from database entries.
"""Build a file of experiment plans for the beamtime from database entries.

The report is in the '.tex' file. The template of the file is in the
'templates/beamplan.tex'. The data will be grouped
Expand Down Expand Up @@ -60,9 +58,8 @@ def _search(db, key):
return None

def _gather_info(self, bt, docs):
"""
Query information from the list of documents. Return a table as the summary of the plans and a list of
experiment plans.
"""Query information from the list of documents. Return a table as the
summary of the plans and a list of experiment plans.

Parameters
----------
Expand Down
Loading