Skip to content

Commit

Permalink
chore(linter): add isort & black
Browse files Browse the repository at this point in the history
Configs for `isort` and `black` are placed in `pyproject.toml`
Pre-commit hooks are set.
Github action workflow `lint` is also added. Only checked push are
permitted to trigger a release.
  • Loading branch information
leonardodalinky committed Sep 25, 2023
1 parent 8e55104 commit eeff8e5
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 15 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,31 @@ on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8
- run: pip install -r requirements.txt
- uses: isort/isort-action@master
with:
isortVersion: '5.12.0'
- uses: psf/black@stable
with:
version: '23.9.0'

semantic-release:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
# wait until test & lint complete
needs: ['lint']
# needs: ['lint', 'test']
steps:
- uses: actions/checkout@v3
Expand Down
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-case-conflict
- id: trailing-whitespace
- id: end-of-file-fixer
- id: name-tests-test
- id: requirements-txt-fixer
- id: detect-private-key
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black", "--line-length=100", "--python-version=38"]
- repo: https://github.com/psf/black
rev: 23.9.0
hooks:
- id: black
args: ["--line-length=100", "--target-version=py38"]
39 changes: 39 additions & 0 deletions CONTRIBUTE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Contributing to the project

This project is still under construction. We welcome any contributions. Please **carefully** read the following instructions before contributing.

## Code style

We use `isort` with `black` to enforce a consistent code style.
```shell
pip install isort==5.12.0 black==23.9.0
```

Configs can be found in `pyproject.toml`.

CI also checks code style before pushing to `main` branch. Try to run `isort` and `black` locally before pushing to avoid unnecessary CI failures:
```shell
isort .
black .
```

### Pre-commit hook

To automatically run `isort` and `black` before each commit, install `pre-commit`:
```shell
pip install pre-commit
```

Then run `pre-commit install` to install the hook.

## Commit message

Check out [this article](https://www.conventionalcommits.org/en/v1.0.0/) for a detailed explanation of how to write a good commit message.

Commit messages started with `feat` will trigger a major version bump, `fix` will trigger a minor version bump.

Also check out [semantic-release](https://github.com/semantic-release/semantic-release) for details.

## Test

⚠ Under construction. ⚠
6 changes: 5 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Quickstart

.. code-block:: python
import asyncio
import logging
Expand Down Expand Up @@ -69,3 +69,7 @@ Supported python versions:
- 3.11
- 3.10
- 3.9

Contributing
------------
Contributions are always welcome! Please read the `contributing guidelines <CONTRIBUTE.md>`__ first.
2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ endpoints
- Item class inherits from WorldstateObject and MultiQueryModel
- Put all major infos in the Item class (split them later)

- Test compatibility with Python 3.8

## Version 2.0

- Remove `WorldstateClient.query_list_of(type)` as `WorldstateClient.query(type)` now does the same while keeping the type.
12 changes: 11 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
build-backend = "setuptools.build_meta"

[tool.isort]
profile = "black"
py_version = "38"
line_length = 100

[tool.black]
line-length = 100
target-version = ["py38"]
include = '\.pyi?$'
16 changes: 8 additions & 8 deletions warframe/worldstate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from .alert import *
from .arbitration import *
from .archon_hunt import *
from .cambion_drift import *
from .cetus import *
from .counted_item import *
from .daily_deal import *
from .event import *
from .fissure import *
from .flash_sale import *
from .invasion import *
from .mission import *
from .orb_vallis import *
from .arbitration import *
from .counted_item import *
from .reward import *
from .mission import *
from .invasion import *
from .void_trader import *
from .fissure import *
from .archon_hunt import *
from .sortie import *
from .event import *
from .void_trader import *
5 changes: 2 additions & 3 deletions warframe/worldstate/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

from msgspec import field

from .reward import Reward

from ..common import MultiQueryModel, TimedEvent
from ..enums import MissionType, Faction, Syndicate
from ..enums import Faction, MissionType, Syndicate
from .reward import Reward

__all__ = ["Event"]

Expand Down
2 changes: 1 addition & 1 deletion warframe/worldstate/models/sortie.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from msgspec import field

from ..common import SingleQueryModel, TimedEvent
from ..enums import MissionType, Faction
from ..enums import Faction, MissionType

__all__ = ["Sortie"]

Expand Down
2 changes: 1 addition & 1 deletion warframe/worldstate/models/void_trader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from msgspec import field

from ..common import SingleQueryModel, WorldstateObject, TimedEvent
from ..common import SingleQueryModel, TimedEvent, WorldstateObject

__all__ = ["VoidTrader"]

Expand Down

0 comments on commit eeff8e5

Please sign in to comment.