Skip to content

Commit bb510d4

Browse files
CyclingNinjapre-commit-ci[bot]nabobalis
authored
Updates in line with package template (#162)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Nabil Freij <[email protected]>
1 parent 17f7979 commit bb510d4

File tree

11 files changed

+159
-70
lines changed

11 files changed

+159
-70
lines changed

.cruft.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "https://github.com/sunpy/package-template",
3-
"commit": "7b0225e0a206b7b6249752991334dea7e9ffcfd4",
3+
"commit": "4ca8e60aac805d5f736de80c45ae0aba96b4cb85",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
@@ -16,7 +16,8 @@
1616
"enable_dynamic_dev_versions": "y",
1717
"include_example_code": "n",
1818
"include_cruft_update_github_workflow": "y",
19-
"_sphinx_theme": "alabaster",
19+
"use_extended_ruff_linting": "y",
20+
"_sphinx_theme": "sunpy",
2021
"_parent_project": "",
2122
"_install_requires": "",
2223
"_copy_without_render": [

.github/workflows/sub_package_update.yml

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ jobs:
2121
runs-on: ubuntu-latest
2222
strategy:
2323
fail-fast: true
24-
matrix:
25-
include:
26-
- add-paths: .
27-
body: apply the changes to this repo.
28-
branch: cruft/update
29-
commit-message: "Automatic package template update"
30-
title: Updates from the package template
31-
3224
steps:
3325
- uses: actions/checkout@v4
3426

@@ -37,7 +29,7 @@ jobs:
3729
python-version: "3.11"
3830

3931
- name: Install Cruft
40-
run: python -m pip install git+https://github.com/Cadair/cruft@patch-p1
32+
run: python -m pip install cruft
4133

4234
- name: Check if update is available
4335
continue-on-error: false
@@ -55,25 +47,47 @@ jobs:
5547
echo "has_changes=$CHANGES" >> "$GITHUB_OUTPUT"
5648
5749
- name: Run update if available
50+
id: cruft_update
5851
if: steps.check.outputs.has_changes == '1'
5952
run: |
6053
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
6154
git config --global user.name "${{ github.actor }}"
6255
63-
cruft update --skip-apply-ask --refresh-private-variables
56+
cruft_output=$(cruft update --skip-apply-ask --refresh-private-variables)
57+
echo $cruft_output
6458
git restore --staged .
6559
66-
- name: Create pull request
60+
if [[ "$cruft_output" == *"Failed to cleanly apply the update, there may be merge conflicts."* ]]; then
61+
echo merge_conflicts=1 >> $GITHUB_OUTPUT
62+
else
63+
echo merge_conflicts=0 >> $GITHUB_OUTPUT
64+
fi
65+
66+
- name: Check if only .cruft.json is modified
67+
id: cruft_json
6768
if: steps.check.outputs.has_changes == '1'
69+
run: |
70+
git status --porcelain=1
71+
if [[ "$(git status --porcelain=1)" == " M .cruft.json" ]]; then
72+
echo "Only .cruft.json is modified. Exiting workflow early."
73+
echo "has_changes=0" >> "$GITHUB_OUTPUT"
74+
else
75+
echo "has_changes=1" >> "$GITHUB_OUTPUT"
76+
fi
77+
78+
- name: Create pull request
79+
if: steps.cruft_json.outputs.has_changes == '1'
6880
uses: peter-evans/create-pull-request@v7
6981
with:
7082
token: ${{ secrets.GITHUB_TOKEN }}
71-
add-paths: ${{ matrix.add-paths }}
72-
commit-message: ${{ matrix.commit-message }}
73-
branch: ${{ matrix.branch }}
83+
add-paths: "."
84+
commit-message: "Automatic package template update"
85+
branch: "cruft/update"
7486
delete-branch: true
75-
branch-suffix: timestamp
76-
title: ${{ matrix.title }}
87+
draft: ${{ steps.cruft_update.outputs.merge_conflicts == '1' }}
88+
title: "Updates from the package template"
7789
body: |
78-
This is an autogenerated PR, which will ${{ matrix.body }}.
79-
[Cruft](https://cruft.github.io/cruft/) has detected updates from the Package Template
90+
This is an autogenerated PR, which will applies the latest changes from the [SunPy Package Template](https://github.com/sunpy/package-template).
91+
If this pull request has been opened as a draft there are conflicts which need fixing.
92+
93+
**To run the CI on this pull request you will need to close it and reopen it.**

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
repos:
22
# This should be before any formatting hooks like isort
33
- repo: https://github.com/astral-sh/ruff-pre-commit
4-
rev: "v0.6.9"
4+
rev: "v0.7.0"
55
hooks:
66
- id: ruff
77
args: ["--fix"]

.ruff.toml

Lines changed: 71 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,91 @@
11
target-version = "py310"
2-
line-length = 110
3-
exclude = [
4-
".git,",
5-
"__pycache__",
6-
"build",
7-
"sunpy_soar/version.py",
8-
"tools/**",
2+
line-length = 120
3+
exclude=[
4+
".git,",
5+
"__pycache__",
6+
"build",
7+
"tools/**",
98
]
109

1110
[lint]
12-
select = ["E", "F", "W", "UP", "PT"]
11+
select = [
12+
"E",
13+
"F",
14+
"W",
15+
"N",
16+
"UP",
17+
"PT",
18+
"BLE",
19+
"A",
20+
"C4",
21+
"INP",
22+
"PIE",
23+
"T20",
24+
"RET",
25+
"TID",
26+
"PTH",
27+
"PD",
28+
"PLC",
29+
"PLE",
30+
"FLY",
31+
"NPY",
32+
"PERF",
33+
"RUF",
34+
]
35+
1336
extend-ignore = [
1437
# pycodestyle (E, W)
15-
"E501", # LineTooLong # TODO! fix
38+
"E501", # ignore line length will use a formatter instead
39+
# pyupgrade (UP)
40+
"UP038", # Use | in isinstance - not compatible with models and is slower
1641
# pytest (PT)
1742
"PT001", # Always use pytest.fixture()
1843
"PT004", # Fixtures which don't return anything should have leading _
19-
"PT007", # Parametrize should be lists of tuples # TODO! fix
20-
"PT011", # Too broad exception assert # TODO! fix
2144
"PT023", # Always use () on pytest decorators
45+
# flake8-pie (PIE)
46+
"PIE808", # Disallow passing 0 as the first argument to range
47+
# flake8-use-pathlib (PTH)
48+
"PTH123", # open() should be replaced by Path.open()
49+
# Ruff (RUF)
50+
"RUF003", # Ignore ambiguous quote marks, doesn't allow ' in comments
51+
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
52+
"RUF013", # PEP 484 prohibits implicit `Optional`
53+
"RUF015", # Prefer `next(iter(...))` over single element slice
2254
]
2355

2456
[lint.per-file-ignores]
25-
# Part of configuration, not a package.
26-
"setup.py" = ["INP001"]
27-
"conftest.py" = ["INP001"]
57+
"examples/*.py" = [
58+
"INP001", # Implicit namespace package
59+
"T201", # Use print
60+
"B018", # Not print but display
61+
"ERA001", # Commented out code
62+
]
63+
"setup.py" = [
64+
"INP001", # File is part of an implicit namespace package.
65+
]
66+
"conftest.py" = [
67+
"INP001", # File is part of an implicit namespace package.
68+
]
2869
"docs/conf.py" = [
29-
"E402" # Module imports not at top of file
70+
"E402", # Module imports not at top of file
71+
"INP001", # conf.py is part of an implicit namespace package
3072
]
3173
"docs/*.py" = [
32-
"INP001", # Implicit-namespace-package. The examples are not a package.
74+
"INP001", # File is part of an implicit namespace package.
75+
]
76+
"examples/**.py" = [
77+
"T201", # allow use of print in examples
78+
"INP001", # File is part of an implicit namespace package.
79+
]
80+
"__init__.py" = [
81+
"E402", # Module level import not at top of cell
82+
"F401", # Unused import
83+
"F403", # from {name} import * used; unable to detect undefined names
84+
"F405", # {name} may be undefined, or defined from star imports
85+
]
86+
"test_*.py" = [
87+
"E402", # Module level import not at top of cell
3388
]
34-
"__init__.py" = ["E402", "F401", "F403"]
35-
"test_*.py" = ["B011", "D", "E402", "PGH001", "S101"]
3689

3790
[lint.pydocstyle]
3891
convention = "numpy"

docs/conf.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
# The full version, including alpha/beta/rc tags
1515
from sunpy_soar import __version__
1616

17+
# -- Project information -----------------------------------------------------
18+
19+
1720
_version = Version(__version__)
1821
version = release = str(_version)
1922
# Avoid "post" appearing in version string in rendered docs
@@ -26,7 +29,7 @@
2629
is_release = not(_version.is_prerelease or _version.is_devrelease)
2730

2831
project = "sunpy-soar"
29-
copyright = f"{datetime.datetime.now().year}, The SunPy Community" # NOQA: A001, DTZ005
32+
copyright = f"{datetime.datetime.now().year}, The SunPy Community" # noqa: A001
3033
author = "The SunPy Community"
3134

3235
# -- General configuration ---------------------------------------------------
@@ -50,7 +53,7 @@
5053
]
5154

5255
# Add any paths that contain templates here, relative to this directory.
53-
# templates_path = ["_templates"] # NOQA: ERA001
56+
# templates_path = ["_templates"]
5457

5558
# List of patterns, relative to source directory, that match files and
5659
# directories to ignore when looking for source files.
@@ -67,6 +70,9 @@
6770
# Treat everything in single ` as a Python reference.
6871
default_role = "py:obj"
6972

73+
# Treat everything in single ` as a Python reference.
74+
default_role = "py:obj"
75+
7076
# -- Options for intersphinx extension ---------------------------------------
7177

7278
intersphinx_mapping = {
@@ -91,6 +97,22 @@
9197
"parfive": ("https://parfive.readthedocs.io/en/stable/", None),
9298
}
9399

100+
# The theme to use for HTML and HTML Help pages. See the documentation for
101+
# a list of builtin themes.
102+
html_theme = "sunpy"
103+
104+
# Render inheritance diagrams in SVG
105+
graphviz_output_format = "svg"
106+
107+
graphviz_dot_args = [
108+
"-Nfontsize=10",
109+
"-Nfontname=Helvetica Neue, Helvetica, Arial, sans-serif",
110+
"-Efontsize=10",
111+
"-Efontname=Helvetica Neue, Helvetica, Arial, sans-serif",
112+
"-Gfontsize=10",
113+
"-Gfontname=Helvetica Neue, Helvetica, Arial, sans-serif",
114+
]
115+
94116
# -- Options for HTML output -------------------------------------------------
95117

96118
# The theme to use for HTML and HTML Help pages. See the documentation for
@@ -112,7 +134,7 @@
112134
# Add any paths that contain custom static files (such as style sheets) here,
113135
# relative to this directory. They are copied after the builtin static files,
114136
# so a file named "default.css" will overwrite the builtin "default.css".
115-
# html_static_path = ["_static"] # NOQA: ERA001
137+
# html_static_path = ["_static"]
116138

117139
# By default, when rendering docstrings for classes, sphinx.ext.autodoc will
118140
# make docs with the class-level docstring and the class-method docstrings,

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ tests = [
3232
"responses>=0.20.0",
3333
"sunpy[map,net]>=6.0.0",
3434
]
35+
3536
docs = [
3637
"sphinx",
3738
"sphinx-automodapi",

sunpy_soar/_dev/scm_version.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
try:
66
from setuptools_scm import get_version
77

8-
version = get_version(root=Path("..") / "..", relative_to=__file__)
9-
except ImportError as e:
10-
msg = "setuptools_scm not installed"
11-
raise ImportError(msg) from e
8+
version = get_version(root=Path('../..'), relative_to=__file__)
9+
except ImportError:
10+
raise
1211
except Exception as e:
13-
msg = f"setuptools_scm broken with {e}"
14-
raise ValueError(msg) from e
12+
raise ValueError('setuptools_scm can not determine version.') from e

sunpy_soar/attrs.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Distance(Range):
5151
"""
5252

5353
@quantity_input(dist_min=u.m, dist_max=u.m)
54-
def __init__(self, dist_min: u.Quantity, dist_max: u.Quantity): # NOQA: ANN204
54+
def __init__(self, dist_min: u.Quantity, dist_max: u.Quantity):
5555
# Ensure both dist_min and dist_max are scalar values
5656
if not all([dist_min.isscalar, dist_max.isscalar]):
5757
msg = "Both dist_min and dist_max must be scalar values."
@@ -133,14 +133,14 @@ def apply_and(wlk, and_attr, params) -> None:
133133

134134

135135
@walker.add_applier(a.Time)
136-
def _(wlk, attr, params) -> None: # NOQA: ARG001
136+
def _(wlk, attr, params) -> None:
137137
start = attr.start.strftime("%Y-%m-%d %H:%M:%S")
138138
end = attr.end.strftime("%Y-%m-%d %H:%M:%S")
139139
params.append(f"begin_time>='{start}' AND begin_time<='{end}'")
140140

141141

142142
@walker.add_applier(a.Level)
143-
def _(wlk, attr, params) -> None: # NOQA: ARG001
143+
def _(wlk, attr, params) -> None:
144144
level = attr.value
145145
if isinstance(level, int):
146146
level = f"L{level}"
@@ -158,39 +158,39 @@ def _(wlk, attr, params) -> None: # NOQA: ARG001
158158

159159

160160
@walker.add_applier(a.Instrument)
161-
def _(wlk, attr, params) -> None: # NOQA: ARG001
161+
def _(wlk, attr, params) -> None:
162162
params.append(f"instrument='{attr.value}'")
163163

164164

165165
@walker.add_applier(Product)
166-
def _(wlk, attr, params) -> None: # NOQA: ARG001
166+
def _(wlk, attr, params) -> None:
167167
params.append(f"descriptor='{attr.value}'")
168168

169169

170170
@walker.add_applier(a.Provider)
171-
def _(wlk, attr, params) -> None: # NOQA: ARG001
171+
def _(wlk, attr, params) -> None:
172172
params.append(f"provider='{attr.value}'")
173173

174174

175175
@walker.add_applier(SOOP)
176-
def _(wlk, attr, params) -> None: # NOQA: ARG001
176+
def _(wlk, attr, params) -> None:
177177
params.append(f"soop_name='{attr.value}'")
178178

179179

180180
@walker.add_applier(a.Detector)
181-
def _(wlk, attr, params) -> None: # NOQA: ARG001
181+
def _(wlk, attr, params) -> None:
182182
params.append(f"Detector='{attr.value}'")
183183

184184

185185
@walker.add_applier(a.Wavelength)
186-
def _(wlk, attr, params) -> None: # NOQA: ARG001
186+
def _(wlk, attr, params) -> None:
187187
wavemin = attr.min.value
188188
wavemax = attr.max.value
189189
params.append(f"Wavemin='{wavemin}' AND Wavemax='{wavemax}'")
190190

191191

192192
@walker.add_applier(Distance)
193-
def _(wlk, attr, params): # NOQA: ARG001
193+
def _(wlk, attr, params):
194194
# The `Distance` attribute is used to filter the query by solar distance
195195
# without relying on a specific distance column. It is commonly used
196196
# to filter the query without time consideration.

0 commit comments

Comments
 (0)