From 9c6f81cf2b713f4da609b6b428216747142eb0a7 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Fri, 16 Feb 2024 10:00:41 +0000 Subject: [PATCH] Update template --- .cruft.json | 2 +- .flake8 | 27 ++++++++ .gitignore | 137 +++++++++++++++++++++++++++++++++++----- .pre-commit-config.yaml | 59 ++++++++++------- .readthedocs.yaml | 29 +++++++++ .rtd-environment.yml | 7 ++ .ruff.toml | 39 ++++++++++++ tox.ini | 8 +++ 8 files changed, 269 insertions(+), 39 deletions(-) create mode 100644 .flake8 create mode 100644 .readthedocs.yaml create mode 100644 .rtd-environment.yml create mode 100644 .ruff.toml diff --git a/.cruft.json b/.cruft.json index 6426d87..b5ca1fc 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,6 +1,6 @@ { "template": "https://github.com/sunpy/package-template", - "commit": "013e2e3a2a1fd703718f77afdc3fd851699cae40", + "commit": "c26a53f1c7e99ec96ba4016f48752293b1d21dca", "checkout": null, "context": { "cookiecutter": { diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..ab006f9 --- /dev/null +++ b/.flake8 @@ -0,0 +1,27 @@ +[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 + streamtracer/__init__.py, +rst-directives = + plot diff --git a/.gitignore b/.gitignore index 253976b..39616ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,10 @@ +### Python: https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class +tmp/ # C extensions .coverage @@ -9,6 +12,7 @@ __pycache__/ .asv/* # Distribution / packaging .Python +pip-wheel-metadata/ build/ develop-eggs/ dist/ @@ -94,13 +98,6 @@ ipython_config.py # install all needed dependencies. #Pipfile.lock -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - # pdm # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. #pdm.lock @@ -128,10 +125,6 @@ ENV/ env.bak/ venv.bak/ -# Spyder project settings -.spyderproject -.spyproject - # Rope project settings .ropeproject @@ -140,17 +133,131 @@ venv.bak/ # mypy .mypy_cache/ -.dmypy.json -dmypy.json # Pyre type checker .pyre/ +# IDE +# PyCharm +.idea + +# Spyder project settings +.spyderproject +.spyproject + +### VScode: https://raw.githubusercontent.com/github/gitignore/master/Global/VisualStudioCode.gitignore +.vscode/* +.vs/* + +### https://raw.github.com/github/gitignore/master/Global/OSX.gitignore +.DS_Store +.AppleDouble +.LSOverride + +# Icon must ends with two \r. +Icon + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +### Linux: https://raw.githubusercontent.com/github/gitignore/master/Global/Linux.gitignore +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + # pytype static type analyzer .pytype/ -# Cython debug symbols -cython_debug/ +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Windows: https://raw.githubusercontent.com/github/gitignore/master/Global/Windows.gitignore + +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +### Extra Python Items and SunPy Specific +docs/whatsnew/latest_changelog.txt +examples/**/*.csv +figure_test_images* +tags +baseline + +# Release script +.github_cache + +# Misc Stuff +.history +*.orig +.tmp +node_modules/ +package-lock.json +package.json +.prettierrc + +# Log files generated by 'vagrant up' +*.log +# Rust specific stuff target/* Cargo.lock diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ff0d46d..69e5be5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,28 +1,41 @@ - repos: - # Sort order of Python imports - - repo: https://github.com/pycqa/isort - rev: 5.13.2 - hooks: - - id: isort - # Python code formatting - - repo: https://github.com/psf/black - rev: 24.2.0 + # This should be before any formatting hooks like isort + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: "v0.2.1" + hooks: + - id: ruff + args: ["--fix"] + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-ast + - id: check-case-conflict + - id: trailing-whitespace + exclude: ".*(.fits|.fts|.fit|.header|.txt)$" + - id: check-yaml + - id: debug-statements + - id: check-added-large-files + args: ["--enforce-all", "--maxkb=1054"] + - id: end-of-file-fixer + exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|.json)$|^CITATION.rst$" + - id: mixed-line-ending + exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*)$" + # Run mypy type validation + - repo: https://github.com/pre-commit/mirrors-mypy + rev: 'v1.8.0' hooks: - - id: black - # Remove unused Python imports - - repo: https://github.com/PyCQA/autoflake - rev: v2.2.1 - hooks: - - id: autoflake - args: ["--in-place", "--remove-all-unused-imports", "--ignore-init-module-imports"] - # Run mypy type validation - - repo: https://github.com/pre-commit/mirrors-mypy - rev: 'v1.8.0' - hooks: - - id: mypy - additional_dependencies: [types-setuptools] - + - id: mypy + additional_dependencies: [types-setuptools] + # Sort order of Python imports + - repo: https://github.com/pycqa/isort + rev: 5.13.2 + hooks: + - id: isort + # Python code formatting + - repo: https://github.com/psf/black + rev: 24.2.0 + hooks: + - id: black ci: autofix_prs: false diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..790abab --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,29 @@ +version: 2 + +build: + os: ubuntu-22.04 + tools: + python: "mambaforge-4.10" + jobs: + post_checkout: + - git fetch --unshallow || true + pre_install: + - git update-index --assume-unchanged .rtd-environment.yml docs/conf.py + +conda: + environment: .rtd-environment.yml + +sphinx: + builder: html + configuration: docs/conf.py + fail_on_warning: false + +formats: + - htmlzip + +python: + install: + - method: pip + extra_requirements: + - docs + path: . diff --git a/.rtd-environment.yml b/.rtd-environment.yml new file mode 100644 index 0000000..cec7b18 --- /dev/null +++ b/.rtd-environment.yml @@ -0,0 +1,7 @@ +name: streamtracer +channels: + - conda-forge +dependencies: + - python=3.10 + - pip + - graphviz!=2.42.*,!=2.43.* diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..67aab70 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,39 @@ +target-version = "py310" +line-length = 110 +exclude = [ + ".git,", + "__pycache__", + "build", + "streamtracer/version.py", +] + +[lint] +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 +"streamtracer/net/__init__.py" = ["F811"] + +[pydocstyle] +convention = "numpy" diff --git a/tox.ini b/tox.ini index f73e85b..d9be141 100644 --- a/tox.ini +++ b/tox.ini @@ -17,6 +17,14 @@ description = oldestdeps: with the oldest supported version of key dependencies devdeps: with the latest developer version of key dependencies +pass_env = + # Custom compiler locations (such as ccache) + CC + # Location of locales (needed by sphinx on some systems) + LOCALE_ARCHIVE + # If the user has set a LC override we should follow it + LC_ALL + set_env = MPLBACKEND=agg devdeps: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/astropy/simple https://pypi.anaconda.org/scientific-python-nightly-wheels/simple