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

update github actions and add black linter for PRs #475

Merged
merged 45 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d8b41be
update pypi action to use OIDC trusted publisher mgmt
JessicaS11 Dec 12, 2023
9945fe5
run pre-commit autoupdate (updated black hook)
JessicaS11 Dec 13, 2023
9c43911
add note on how to autoupdate hooks
JessicaS11 Dec 13, 2023
4e317ff
update flake8 action
JessicaS11 Dec 13, 2023
cfc9a67
add black to linter action
JessicaS11 Dec 13, 2023
c1ddd08
add dev branch tag for uml diagrams
JessicaS11 Dec 13, 2023
6df815f
Merge branch 'development' into pypi
JessicaS11 Dec 13, 2023
a689312
run black on docs
JessicaS11 Dec 13, 2023
cc5c084
ignore init module unused error in flake8 linting
JessicaS11 Dec 14, 2023
752b683
fix syntax
JessicaS11 Dec 14, 2023
1f8e90e
Merge branch 'development' into pypi
JessicaS11 Dec 14, 2023
901d73e
fix syntax again
JessicaS11 Dec 14, 2023
36b33dc
try changing path syntax
JessicaS11 Dec 14, 2023
233b7ab
try another glob pattern
JessicaS11 Dec 14, 2023
bdf3513
try a different grep path
JessicaS11 Dec 14, 2023
69643dc
fix directory level relative path
JessicaS11 Dec 14, 2023
847fc34
try with no path
JessicaS11 Dec 14, 2023
6fc265c
try without quotes
JessicaS11 Dec 14, 2023
1814585
try with no quotes whatsoever
JessicaS11 Dec 14, 2023
c4ddb79
and now also without the dash
JessicaS11 Dec 14, 2023
a67dae2
add exception for long lines in test_granules
JessicaS11 Dec 14, 2023
0e32170
try different syntax for multiple per-file-ignores
JessicaS11 Dec 15, 2023
21ba006
try with just granules file
JessicaS11 Dec 15, 2023
8696e96
use argument for both sets of files
JessicaS11 Dec 15, 2023
aa1ed8e
try to capture all init files
JessicaS11 Dec 15, 2023
6e165f9
see if it catches all init files without second argument
JessicaS11 Dec 15, 2023
30bd792
make whole extra argument that works locally a string
JessicaS11 Dec 15, 2023
e96d820
try with each per file ignores on newline
JessicaS11 Dec 15, 2023
0cc13ee
try adding quotes to newlined version
JessicaS11 Dec 15, 2023
ffe6380
comment out second ignore specification for now
JessicaS11 Dec 15, 2023
e456c0f
Merge branch 'development' into pypi
JessicaS11 Dec 15, 2023
3b17b84
switch to using .flake8 config file
JessicaS11 Dec 18, 2023
e4c8473
fix tests dir typo
JessicaS11 Dec 18, 2023
5e97518
fix tests path
JessicaS11 Dec 18, 2023
9886767
Merge branch 'development' into pypi
JessicaS11 Dec 18, 2023
3ae95de
Merge branch 'development' into pypi
JessicaS11 Dec 21, 2023
30c4fbd
Merge branch 'development' into pypi
JessicaS11 Jan 4, 2024
6bf17aa
update flake8 settings to be more lenient
JessicaS11 Jan 4, 2024
0b2306d
update a few doc config files to remove more linting errors
JessicaS11 Jan 4, 2024
df1fc71
reduce max line length and add ignore for failing codes
JessicaS11 Jan 4, 2024
752328e
add extra line
JessicaS11 Jan 4, 2024
1ddcf9a
unindent comment
JessicaS11 Jan 4, 2024
00b0784
move goal comment
JessicaS11 Jan 4, 2024
45e6c67
put comments on separate lines
JessicaS11 Jan 4, 2024
6e74f0d
add more tests to ignore
JessicaS11 Jan 4, 2024
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
41 changes: 41 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -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
17 changes: 0 additions & 17 deletions .github/workflows/flake8_action.yml

This file was deleted.

19 changes: 19 additions & 0 deletions .github/workflows/linter_actions.yml
Original file line number Diff line number Diff line change
@@ -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

7 changes: 4 additions & 3 deletions .github/workflows/publish_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
1 change: 1 addition & 0 deletions .github/workflows/uml_action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Update UML diagrams
on:
pull_request_review:
types: [submitted]
branches: development

jobs:
diagrams:
Expand Down
6 changes: 4 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
repos:
- repo: https://github.com/psf/black
rev: 22.6.0
rev: 23.12.0
hooks:
- id: black
- id: black

# you can run `pre-commit autoupdate` to automatically update to the latest version of hooks!
5 changes: 3 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
17 changes: 13 additions & 4 deletions doc/sphinxext/announce.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------
Expand Down Expand Up @@ -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<name>[^<]+) ")

gitcur = list(os.popen("git shortlog -s " + revision_range).readlines())
Expand All @@ -94,7 +104,6 @@ def get_authors(revision_range):
pre = set(pre)

else:

xpr = re.compile(r"Co-authored-by: (?P<name>[^<]+) ")
cur = set(
xpr.findall(
Expand Down