Skip to content

Commit

Permalink
Merge pull request #7384 from nabobalis/pyproj
Browse files Browse the repository at this point in the history
move to pyproject.toml + dedicated tool configs
  • Loading branch information
nabobalis committed Feb 6, 2024
2 parents b26c991 + f1d2ba2 commit 2be8c2a
Show file tree
Hide file tree
Showing 21 changed files with 424 additions and 456 deletions.
13 changes: 13 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[codespell]
skip = *.asdf,*.fits,*.fts,*.header,*.json,*.xsh,*cache*,*egg*,*extern*,.git,.idea,.tox,_build,*truncated,*.svg,.asv_env,.history
ignore-words-list =
alog,
nd,
nin,
observ,
ot,
te,
upto,
afile,
precessed,
precess
13 changes: 13 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[run]
omit =
sunpy/cython_version*
sunpy/extern/*
sunpy/version*
sunpy/data/sample.py
sunpy/data/_sample.py
sunpy/data/test/_generate_asdf_test.py
*/sunpy/cython_version*
*/sunpy/extern/*
*/sunpy/version*
*/sunpy/data/sample.py
*/sunpy/data/_sample.py
21 changes: 10 additions & 11 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# https://editorconfig.org

root = true

root=true
# utf, UNIX-style new line

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset=utf-8
end_of_line=lf
insert_final_newline=true
trim_trailing_whitespace=true

[*.{py,rst,md}]
indent_style = space
indent_size = 4
indent_style=space
indent_size=4

[*.yml]
indent_style = space
indent_size = 2
indent_style=space
indent_size=2
29 changes: 29 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[flake8]
ignore =
# missing-whitespace-around-operator
E225
# missing-whitespace-around-arithmetic-operator
E226
# line-too-long
E501
# unused-import
F401
# undefined-local-with-import-star
F403
# redefined-while-unused
F811
# Line break occurred before a binary operator
W503,
# Line break occurred after a binary operator
W504
max-line-length = 110
exclude =
.git
__pycache__
docs/conf.py
build
sunpy/data/sample.py
sunpy/extern/**
sunpy/__init__.py,
rst-directives =
plot
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ jobs:
run: |
conda list
cd /tmp
pytest -vvv -r a --pyargs sunpy --cov-report=xml --cov=sunpy --cov-config=$GITHUB_WORKSPACE/setup.cfg $GITHUB_WORKSPACE/docs -n auto
pytest -vvv -r a --pyargs sunpy --cov-report=xml --cov=sunpy --cov-config=$GITHUB_WORKSPACE/pyproject.toml $GITHUB_WORKSPACE/docs -n auto
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ october_M1_flares.csv
aia_map.fits
docs/tutorial/figure.png

### Pycharm(?)
### Pycharm
.idea

# Release script
Expand All @@ -232,6 +232,10 @@ docs/tutorial/figure.png
.history
*.orig
.tmp
node_modules/
package-lock.json
package.json
.prettierrc

# Log files generated by 'vagrant up'
*.log
Expand Down
17 changes: 17 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[settings]
balanced_wrapping = true
skip =
sunpy/extern/
sunpy/cm/__init__.py,
docs/conf.py,
sunpy/__init__.py,
default_section = THIRDPARTY
include_trailing_comma = true
known_astropy = astropy, asdf
known_first_party = sunpy
length_sort = false
length_sort_sections = stdlib
line_length = 110
multi_line_output = 3
no_lines_before = LOCALFOLDER
sections = STDLIB, THIRDPARTY, ASTROPY, FIRSTPARTY, LOCALFOLDER
9 changes: 5 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ exclude: "\\.asdf$"
repos:
# This should be before any formatting hooks like isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.11"
rev: "v0.1.15"
hooks:
- id: ruff
args: ["--fix"]
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--sp", "setup.cfg"]
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|extern.*|sunpy/extern)$"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
Expand All @@ -22,7 +21,7 @@ repos:
- id: check-yaml
- id: debug-statements
- id: check-added-large-files
args: ['--enforce-all','--maxkb=1054']
args: ["--enforce-all", "--maxkb=1054"]
- id: end-of-file-fixer
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|.json)$|^CITATION.rst$"
- id: mixed-line-ending
Expand All @@ -31,7 +30,9 @@ repos:
rev: v2.2.6
hooks:
- id: codespell
args: ['--config setup.cfg --write-changes']
additional_dependencies:
- tomli
args: ["--write-changes"]
- repo: local
hooks:
- id: generate-sunpy-net-hek-attrs
Expand Down
8 changes: 4 additions & 4 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ formats:
- htmlzip

python:
install:
- method: pip
extra_requirements:
install:
- method: pip
extra_requirements:
- all
- docs
- docs-gallery
path: .
path: .
42 changes: 42 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
target-version = "py310"
line-length = 110
exclude = [
".git,",
"__pycache__",
"build",
"sunpy/extern/**",
"sunpy/version.py",
]
select = ["E", "F", "W", "UP", "PT"]
extend-ignore = [
# pycodestyle (E, W)
"E501", # LineTooLong # TODO! fix
# pytest (PT)
"PT001", # Always use pytest.fixture()
"PT004", # Fixtures which don't return anything should have leading _
"PT007", # Parametrize should be lists of tuples # TODO! fix
"PT011", # Too broad exception assert # TODO! fix
"PT023", # Always use () on pytest decorators
]

[flake8-tidy-imports]
[flake8-tidy-imports.banned-api]
"warnings.warn".msg = "Use sunpy specific warning helpers warn_* from sunpy.utils.exceptions"

[per-file-ignores]
# Part of configuration, not a package.
"setup.py" = ["INP001"]
"conftest.py" = ["INP001"]
# Implicit-namespace-package. The examples are not a package.
"docs/*.py" = ["INP001"]
"__init__.py" = ["E402", "F401", "F403"]
"test_*.py" = ["B011", "D", "E402", "PGH001", "S101"]
# Need to import clients to register them, but don't use them in file
"sunpy/net/__init__.py" = ["F811"]
# These files are allowed to use warnings.warn
"sunpy/util/exceptions.py" = ["TID251"]
"sunpy/util/tests/test_logger.py" = ["TID251"]
"sunpy/util/decorators.py" = ["TID251"]

[pydocstyle]
convention = "numpy"
1 change: 1 addition & 0 deletions changelog/7384.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Moved to ``pyproject.toml`` and removed ``setup.py`` and ``setup.cfg``.
2 changes: 1 addition & 1 deletion docs/dev_guide/contents/code_standards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Language Standard

* The core package and affiliated packages should be importable with no dependencies other than components already in the sunpy core package, the `Python Standard Library <https://docs.python.org/3/library/index.html>`_, and packages already required by the sunpy core package.
Adding dependencies to sunpy core will be considered but are highly discouraged.
Such optional dependencies should be recorded in the ``setup.cfg`` file in the ``extras_require`` entry.
Such optional dependencies should be recorded in the ``pyproject.toml`` file in the ``project.optional-dependencies`` section.

Coding Style/Conventions
========================
Expand Down
2 changes: 1 addition & 1 deletion docs/dev_guide/contents/documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ If you'd like to start from scratch (i.e., remove the tox cache) then change to
tox -r -e build_docs-gallery


To build the documentation in your current python environment you must have all the dependencies specified in ``setup.cfg`` installed (``pip install -e .[docs,docs-gallery]``).
To build the documentation in your current python environment you must have all the dependencies specified in ``pyproject.toml`` installed (``pip install -e .[docs,docs-gallery]``).
Then change to the :file:`docs/` directory and run::

make html
Expand Down
12 changes: 6 additions & 6 deletions docs/dev_guide/contents/tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ The testing framework used by sunpy is the `pytest`_ framework, accessed through
Dependencies for testing
------------------------

Since the testing dependencies are not actually required to install or use sunpy, they are not included in "install_requires" in "setup.cfg".
Since the testing dependencies are not actually required to install or use sunpy, they are not included in "install_requires" in "pyproject.toml".

Developers who want to run the test suite will need to install the testing packages using pip::

$ pip install -e ".[tests]"

If you want to see the current test dependencies, you check "extras_require" in "setup.cfg".
If you want to see the current test dependencies, you check "extras_require" in "pyproject.toml".

Running Tests
=============
Expand Down Expand Up @@ -55,13 +55,13 @@ This is the method that our continuous integration uses.
----------

The test suite can be run directly from the native ``pytest`` command.
In this case, it is important for developers to be aware that they must manually rebuild any extensions by running ``python setup.py build_ext`` before testing.
In this case, it is important for developers to be aware that they must manually rebuild any extensions by running ``pip install -e .`` before testing.

To run the entire suite with ``pytest``::

$ pytest

will use the settings in ``setup.cfg``.
will use the settings in ``pyproject.toml``.

If you want to run one specific test file::

Expand Down Expand Up @@ -163,7 +163,7 @@ or::
Coverage reports
----------------

sunpy can use `pytest-cov`_ generate test coverage reports and settings are stored in ``setup.cfg``.
sunpy can use `pytest-cov`_ generate test coverage reports and settings are stored in ``pyproject.toml``.
This plugin can be installed using `pip`_::

$ pip install pytest-cov
Expand Down Expand Up @@ -331,7 +331,7 @@ Code examples in the documentation will also be run as tests and this helps to v
sunpy uses the same system as Astropy, so for information on writing doctests see the astropy `documentation <https://docs.astropy.org/en/latest/development/testguide.html#writing-doctests>`_.

You do not have to do anything extra in order to run any documentation tests.
Within our ``setup.cfg`` file we have set default options for ``pytest``, such that you only need to run::
Within our ``pyproject.toml`` file we have set default options for ``pytest``, such that you only need to run::

$ pytest <file to test>

Expand Down

0 comments on commit 2be8c2a

Please sign in to comment.