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

Fix * imports #138

Merged
merged 23 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 25 additions & 0 deletions .github/workflows/code-style.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Code style

on:
push:
branches:
- master
pull_request:
branches:
- master
types:
- opened
- reopened
- synchronize
- ready_for_review
workflow_dispatch:

jobs:
codestyle:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: chartboost/ruff-action@v1
with:
changed-files: 'true'
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
---
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.2
hooks:
- id: ruff
args: [--fix]
types_or: [python, pyi]
# - id: ruff-format
# types_or: [python, pyi]
32 changes: 32 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,41 @@ conda activate proteus
pip install -e .[develop]
```

### Linting

Linting is a term for static code analysis to flag programming errors,
bugs, stylistic errors and [suspicious constructs](https://en.wikipedia.org/wiki/Lint_(software)).
PROTEUS uses [`ruff`](https://astral.sh/ruff) for linting.
The linting [rules](https://docs.astral.sh/ruff/rules/) are defined in [`pyproject.toml`](https://github.com/FormingWorlds/PROTEUS/blob/master/pyproject.toml).

This check are run automatically via a Github Action: [codestyle](https://github.com/FormingWorlds/PROTEUS/blob/master/.github/workflows/codestyle.yaml).

You can `ruff` on locally using one of these commands:

```console
ruff check start_proteus.py # single file
ruff check src/proteus # directory
ruff check . # everything
```

If you prepend `--fix`, it can also fix some issues for you:

```console
ruff check . --fix
```

You can also use [pre-commit](https://pre-commit.com/#usage) to automatically run `ruff` on every commit, e.g.:

```console
pre-commit install
```

### Running tests

PROTEUS uses [pytest](https://docs.pytest.org/en/latest/) to run the tests.

The tests are run automatically via a Github Action: [tests](https://github.com/FormingWorlds/PROTEUS/blob/master/.github/workflows/tests.yaml).

You can run the tests for yourself using:

```console
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Tests for PROTEUS](https://github.com/FormingWorlds/actions/workflows/tests.yaml/badge.svg)](https://github.com/FormingWorlds/actions/workflows/tests.yaml)
[![Tests for PROTEUS](https://github.com/FormingWorlds/PROTEUS/actions/workflows/tests.yaml/badge.svg)](https://github.com/FormingWorlds/PROTEUS/actions/workflows/tests.yaml)
![Coverage](https://gist.githubusercontent.com/stefsmeets/b4ee7dab92e20644bcb3a5ad09f71165/raw/covbadge.svg)
[![Documentation Status](https://readthedocs.org/projects/fwl-proteus/badge/?version=latest)](https://fwl-proteus.readthedocs.io/en/latest/?badge=latest)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
Expand Down
29 changes: 29 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ develop = [
"coverage[toml]",
"pip-tools",
"pytest >= 8.1",
"pre-commit",
"ruff",
]

docs = [
Expand All @@ -86,6 +88,33 @@ source = ["proteus"]
[tool.pytest.ini_options]
testpaths = ["tests"]

[tool.ruff]
line-length = 96
target-version = "py310"
extend-exclude = ["*ipynb"]

[tool.ruff.lint]
select = [
# "F", # Pyflakes
# "E", # pycodestyle (error)
# "W", # pycodestyle (warning)
"I", # isort
"F401", # {name} imported but unused
"F402", # from __future__ imports must occur at the beginning of the file
"F403", # from {name} import * only allowed at module level
"F404", # from {name} import * only allowed at module level
"E401", # Multiple imports on one line
"E402", # Module level import not at top of cell
]

[tool.ruff.lint.isort]
known-first-party=["proteus"]
required-imports = ["from __future__ import annotations"]

[tool.ruff.format]
quote-style = "single"
indent-style = "space"

[tool.bumpversion]
# https://callowayproject.github.io/bump-my-version/howtos/calver/
current_version = "24.07.25"
Expand Down
2 changes: 2 additions & 0 deletions src/proteus/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from __future__ import annotations

__version__ = '24.07.25'
5 changes: 5 additions & 0 deletions src/proteus/atmos_clim/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
from __future__ import annotations

from .wrapper_atmosphere import RunAtmosphere

__all__ = [
'RunAtmosphere',
]
Loading
Loading