Skip to content

Commit

Permalink
Bump ruff version, use ruff for import sorting (#8)
Browse files Browse the repository at this point in the history
* Bump ruff version, use ruff for import sorting
* Remove docs on installing nodejs
* Add documentation linting/formatting
* A few more fixes, remove js testing
* Bump minimum test coverage to 75%
* sort dependencies

Signed-off-by: Tim Paine <[email protected]>
  • Loading branch information
timkpaine authored Jul 16, 2024
1 parent 8a9ceb2 commit d613ba7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 48 deletions.
20 changes: 15 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ install: ## install to site-packages
.PHONY: test tests

test: ## run the python unit tests
python -m pytest -v csp_adapter_symphony/tests --junitxml=junit.xml --cov=csp_adapter_symphony --cov-report=xml:.coverage.xml --cov-branch --cov-fail-under=1 --cov-report term-missing
python -m pytest -v csp_adapter_symphony/tests --junitxml=junit.xml --cov=csp_adapter_symphony --cov-report=xml:.coverage.xml --cov-branch --cov-fail-under=75 --cov-report term-missing

test: tests

Expand All @@ -32,15 +32,25 @@ test: tests
###########
.PHONY: lint fix format

lint: ## lint python with isort and ruff
python -m isort csp_adapter_symphony setup.py --check
lint-py: ## lint python with ruff
python -m ruff check csp_adapter_symphony setup.py
python -m ruff format --check csp_adapter_symphony setup.py

fix: ## autoformat python code with isort and ruff
python -m isort csp_adapter_symphony setup.py
lint-docs: ## lint docs with mdformat and codespell
python -m mdformat --check docs/wiki/ README.md
python -m codespell_lib docs/wiki/ README.md

fix-py: ## autoformat python code with ruff
python -m ruff check --fix csp_adapter_symphony setup.py
python -m ruff format csp_adapter_symphony setup.py

fix-docs: ## autoformat docs with mdformat and codespell
python -m mdformat docs/wiki/ README.md
python -m codespell_lib --write docs/wiki/ README.md

lint: lint-py lint-docs ## run all linters
lints: lint
fix: fix-py fix-docs ## run all autoformatters
format: fix

#################
Expand Down
43 changes: 11 additions & 32 deletions docs/wiki/Build-from-Source.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
- [Make commands](#make-commands)
- [Prerequisites](#prerequisites)
- [Clone](#clone)
- [Install NodeJS](#install-nodejs)
- [Install Python dependencies](#install-python-dependencies)
- [Build](#build)
- [Lint and Autoformat](#lint-and-autoformat)
Expand Down Expand Up @@ -40,14 +39,6 @@ git clone https://github.com/Point72/csp-adapter-symphony.git
cd csp-adapter-symphony
```

## Install NodeJS

Follow the instructions for [installing NodeJS](https://nodejs.org/en/download/package-manager/all) for your system. Once installed, you can [install `pnpm`](https://pnpm.io/installation) with:

```bash
npm instal --global pnpm
```

## Install Python dependencies

Python build and develop dependencies are specified in the `pyproject.toml`, but you can manually install them:
Expand All @@ -70,41 +61,35 @@ make build

`csp-adapter-symphony` has linting and auto formatting.

| Language | Linter | Autoformatter | Description |
| :--------- | :--------- | :------------ | :---------- |
| Python | `ruff` | `ruff` | Style |
| Python | `isort` | `isort` | Imports |
| JavaScript | `prettier` | `prettier` | Style |
| Markdown | `prettier` | `prettier` | Style |
| Language | Linter | Autoformatter | Description |
| :------- | :--------- | :------------ | :---------- |
| Python | `ruff` | `ruff` | Style |
| Markdown | `prettier` | `prettier` | Style |

**Python Linting**

```bash
make lintpy
make lint-py
```

**Python Autoformatting**

```bash
make fixpy
make fix-py
```

**JavaScript Linting**
**Documentation Linting**

```bash
make lintjs
make lint-docs
```

**JavaScript Autoformatting**
**Documentation Autoformatting**

```bash
make fixjs
make fix-docs
```

**Documentation Linting**

We use `prettier` for our Markdown linting, so follow the above docs.

## Testing

`csp-adapter-symphony` has both Python and JavaScript tests. The bulk of the functionality is tested in Python, which can be run via `pytest`. First, install the Python development dependencies with
Expand All @@ -116,11 +101,5 @@ make develop
**Python**

```bash
make testpy
```

**JavaScript**

```bash
make testjs
make test
```
25 changes: 14 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ dependencies = [
develop = [
"bump2version>=1.0.0",
"check-manifest",
"codespell>=2.2.6,<2.3",
"hatchling",
"isort",
"ruff>=0.3,<0.5",
"mdformat>=0.7.17,<0.8",
"ruff>=0.5,<0.6",
"twine>=5,<5.2",
# test
"pytest",
Expand Down Expand Up @@ -90,15 +91,6 @@ exclude = [
"/docs",
]

[tool.isort]
combine_as_imports = true
include_trailing_comma = true
line_length = 150
profile = "black"
default_section = "THIRDPARTY"
sections = "FUTURE,THIRDPARTY,FIRSTPARTY,LOCALFOLDER"
known_first_party = "csp_adapter_symphony"

[tool.pytest.ini_options]
asyncio_mode = "strict"
testpaths = "csp_adapter_symphony/tests"
Expand All @@ -108,3 +100,14 @@ line-length = 150

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401", "F403"]

[tool.ruff.lint.isort]
combine-as-imports = true
default-section = "third-party"
known-first-party = ["csp_adapter_symphony"]
section-order = [
"future",
"third-party",
"first-party",
"local-folder",
]

0 comments on commit d613ba7

Please sign in to comment.