diff --git a/.flake8 b/.flake8 new file mode 100644 index 000000000..16b39f3fe --- /dev/null +++ b/.flake8 @@ -0,0 +1,41 @@ +[flake8] +#GOAL: max_line_length = 79 or 99 +max_line_length = 99 +per-file-ignores = + # too many leading '#' for block comment + */tests/*:E266 + # line too long (several test strs) + test_granules.py:E501 + # imported but unused + __init__.py:F401 + # import not at top of file + doc/source/conf.py:E402 + +# GOAL: remove these ignores +ignore = + # line too long + E501 + # comparison syntax + E711 + # comparison syntax + E712 + # comparison syntax in tests + E714 + # comparison syntax in tests + E721 + # bare except + E722 + # ambiguous var name + E741 + # imported but unused + F401 + # unable to detect undefined names + F403 + # assigned and unused (in tests) + F841 + # line break before binary operator + W503 + + # GOAL: + # syntax check doctests in docstrings + # doctests = True \ No newline at end of file diff --git a/.github/workflows/flake8_action.yml b/.github/workflows/flake8_action.yml deleted file mode 100644 index 2e754ad33..000000000 --- a/.github/workflows/flake8_action.yml +++ /dev/null @@ -1,17 +0,0 @@ -# use the flake8 linter to annotate improperly formatted code -# from: https://github.com/marketplace/actions/run-flake8-on-your-pr-with-annotations -name: Run flake8 linter on PRs - -on: - pull_request: - branches: - - development - - master -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Annotate PR after running flake8 - uses: TrueBrain/actions-flake8@master - with: - max_line_length: 88 diff --git a/.github/workflows/linter_actions.yml b/.github/workflows/linter_actions.yml new file mode 100644 index 000000000..dc3836536 --- /dev/null +++ b/.github/workflows/linter_actions.yml @@ -0,0 +1,19 @@ +name: Run linters on PRs + +on: + pull_request: + branches: + - development + - main +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run black linter + uses: psf/black@stable + # use the flake8 linter to annotate improperly formatted code + # note linter arguments are supplied via the .flake8 config file + - name: Annotate PR after running flake8 + uses: TrueBrain/actions-flake8@v2 + diff --git a/.github/workflows/publish_to_pypi.yml b/.github/workflows/publish_to_pypi.yml index e36a321d5..26d6d01cd 100644 --- a/.github/workflows/publish_to_pypi.yml +++ b/.github/workflows/publish_to_pypi.yml @@ -51,12 +51,13 @@ jobs: - name: Publish to Test PyPI uses: pypa/gh-action-pypi-publish@release/v1 + permissions: + id-token: write with: - password: ${{ secrets.TEST_PYPI_API_TOKEN }} repository_url: https://test.pypi.org/legacy/ - name: Publish to PyPI if: startsWith(github.ref, 'refs/tags') + permissions: + id-token: write uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/uml_action.yml b/.github/workflows/uml_action.yml index ba893e5e9..db0a59fa6 100644 --- a/.github/workflows/uml_action.yml +++ b/.github/workflows/uml_action.yml @@ -2,6 +2,7 @@ name: Update UML diagrams on: pull_request_review: types: [submitted] + branches: development jobs: diagrams: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 74a6e3028..57a5b81bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,7 @@ repos: - repo: https://github.com/psf/black - rev: 22.6.0 + rev: 23.12.0 hooks: - - id: black \ No newline at end of file + - id: black + +# you can run `pre-commit autoupdate` to automatically update to the latest version of hooks! \ No newline at end of file diff --git a/doc/source/conf.py b/doc/source/conf.py index 0bc0003a6..a77670850 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -10,12 +10,12 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # +import datetime import os import sys sys.path.insert(0, os.path.abspath("../..")) sys.path.insert(0, os.path.abspath("../sphinxext")) -import datetime import icepyx @@ -121,7 +121,8 @@ def setup(app): # this should possibly be moved to the sphinxext directory as a standalone .py file # -- custom style for pybtex output ------------------------------------------- from pybtex.style.formatting.unsrt import Style as UnsrtStyle -from pybtex.style.labels.alpha import LabelStyle as AlphaLabelStyle + +# from pybtex.style.labels.alpha import LabelStyle as AlphaLabelStyle from pybtex.plugin import register_plugin # I seem to be unable to figure out how to control what is used for the label. It would diff --git a/doc/sphinxext/announce.py b/doc/sphinxext/announce.py index 21bf7a69e..db6858678 100644 --- a/doc/sphinxext/announce.py +++ b/doc/sphinxext/announce.py @@ -17,9 +17,20 @@ The output is utf8 rst. -Custom extension from the Pandas library: https://github.com/pandas-dev/pandas/blob/1.1.x/doc/sphinxext/announce.py +Custom extension from the Pandas library: +https://github.com/pandas-dev/pandas/blob/1.1.x/doc/sphinxext/announce.py Copied 10 August 2020 and subsequently modified. -Specifically, get_authors was adjusted to check for a .mailmap file and use the git through the command line in order to utilize it if present. Using a mailmap file is currently not possible in gitpython (from git import Repo), and the recommended solution is to bring in the mailmap file yourself and use it to modify the author list (i.e. replicate the functionality that already exists in git). This felt a bit out of time-scope for right now. Alternatively, the git-fame library (imported as gitfame) uses the mailmap file and compiles statistics, but the python wrapper for this command line tool was taking forever. So, I've reverted to using os.system to use git behind the scenes instead. +Specifically, get_authors was adjusted to check for a .mailmap file +and use the git through the command line in order to utilize it if present. +Using a mailmap file is currently not possible in gitpython +(from git import Repo), and the recommended solution is to +bring in the mailmap file yourself and use it to modify the author list +(i.e. replicate the functionality that already exists in git). +This felt a bit out of time-scope for right now. +Alternatively, the git-fame library (imported as gitfame) +uses the mailmap file and compiles statistics, +but the python wrapper for this command line tool was taking forever. +So, I've reverted to using os.system to use git behind the scenes instead. Dependencies ------------ @@ -76,7 +87,6 @@ def get_authors(revision_range): # "Co-authored by" commits, which come from backports by the bot, # and one for regular commits. if ".mailmap" in os.listdir(this_repo.git.working_dir): - xpr = re.compile(r"Co-authored-by: (?P[^<]+) ") gitcur = list(os.popen("git shortlog -s " + revision_range).readlines()) @@ -94,7 +104,6 @@ def get_authors(revision_range): pre = set(pre) else: - xpr = re.compile(r"Co-authored-by: (?P[^<]+) ") cur = set( xpr.findall(