Skip to content

Commit b7938ab

Browse files
authored
Merge pull request #44 from Fortnite-API/ruff
Ruff
2 parents e258fe0 + 02cd906 commit b7938ab

19 files changed

Lines changed: 83 additions & 94 deletions

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# format code with ruff
2+
1655999065f0d8bd6d26597a0f527a2242d5f11e

.github/workflows/lint.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: lint
2+
3+
on:
4+
push:
5+
pull_request:
6+
types: [ opened, reopened, synchronize ]
7+
8+
jobs:
9+
ruff:
10+
permissions:
11+
contents: read
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v5
15+
16+
- name: Get Ruff Version
17+
id: ruff-version
18+
run: echo "version=$(grep -Po '(?<=ruff==)[0-9]+\.[0-9]+\.[0-9]+' pyproject.toml)" >> $GITHUB_OUTPUT
19+
20+
- uses: astral-sh/ruff-action@v3
21+
with:
22+
version: ${{ steps.ruff-version.outputs.version }}

.github/workflows/test.yml

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This workflow will ensure that the pushed contents to the repo
2-
# are not majorly breaking, and they comply with black standards.
2+
# are not majorly breaking.
33

44
name: Pytests
55

@@ -34,52 +34,4 @@ jobs:
3434
shell: bash
3535
env:
3636
TEST_API_KEY: ${{ secrets.TEST_API_KEY }}
37-
run: python -m pytest --cov=fortnite_api --import-mode=importlib -vs tests/
38-
39-
black:
40-
name: Black Formatting Check
41-
runs-on: ubuntu-latest
42-
43-
# Checkout the repository
44-
steps:
45-
- name: Checkout
46-
uses: actions/checkout@v5
47-
48-
- name: Setup Python 3.9
49-
uses: actions/setup-python@v6
50-
with:
51-
python-version: "3.9"
52-
cache: "pip" # Cache the pip packages to speed up the workflow
53-
54-
- name: Install Dependencies and Project
55-
run: |
56-
python -m pip install -U pip setuptools
57-
pip install -U -r requirements.txt
58-
pip install -e .[dev]
59-
60-
- name: Run Black Check
61-
run: black --check --diff --verbose fortnite_api
62-
63-
isort:
64-
name: Isort Formatting Check
65-
runs-on: ubuntu-latest
66-
67-
# Checkout the repository
68-
steps:
69-
- name: Checkout
70-
uses: actions/checkout@v5
71-
72-
- name: Setup Python 3.9
73-
uses: actions/setup-python@v6
74-
with:
75-
python-version: "3.9"
76-
cache: "pip" # Cache the pip packages to speed up the workflow
77-
78-
- name: Install Dependencies and Project
79-
run: |
80-
python -m pip install -U pip setuptools
81-
pip install -U -r requirements.txt
82-
pip install -e .[dev]
83-
84-
- name: Run Isort Check
85-
run: isort --check --diff fortnite_api
37+
run: python -m pytest --cov=fortnite_api --import-mode=importlib -vs tests/

.pre-commit-config.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# Black formatter pre commit hook
22
repos:
3-
- repo: https://github.com/psf/black
4-
rev: 24.10.0
3+
- repo: https://github.com/astral-sh/ruff-pre-commit
4+
rev: v0.13.2
55
hooks:
6-
- id: black
7-
8-
- repo: https://github.com/pycqa/isort
9-
rev: 5.13.2
10-
hooks:
11-
- id: isort
12-
name: isort (python)
6+
# Run the linter.
7+
- id: ruff-check
8+
args: [ --fix ]
9+
# Run the formatter.
10+
- id: ruff-format

docs/extensions/outdated_code_blocks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ class OutdatedCodeBlock(CodeBlock):
118118
}
119119

120120
def run(self) -> list[Node]:
121-
122121
# Create the main node that holds the code block and warning
123122
root = OutdatedCodeBlockNode()
124123

@@ -144,7 +143,8 @@ def setup(app: Sphinx):
144143
app.add_node(OutdatedCodeBlockNode, html=(visit_outdated_code_block_node, depart_outdated_code_block_node)) # type: ignore
145144
app.add_node(OutdatedCodeBlockWarning, html=(visit_outdated_code_block_warning, depart_outdated_code_block_warning)) # type: ignore
146145
app.add_node( # type: ignore
147-
OutdatedCodeBlockWarningText, html=(visit_outdated_code_block_warning_text, depart_outdated_code_block_warning_text)
146+
OutdatedCodeBlockWarningText,
147+
html=(visit_outdated_code_block_warning_text, depart_outdated_code_block_warning_text),
148148
)
149149

150150
app.add_directive('outdated-code-block', OutdatedCodeBlock)

fortnite_api/client.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@
3737
from .aes import Aes
3838
from .all import CosmeticsAll
3939
from .banner import Banner, BannerColor
40-
from .cosmetics import CosmeticBr, CosmeticCar, CosmeticInstrument, CosmeticLegoKit, CosmeticTrack, VariantBean, VariantLego
40+
from .cosmetics import (
41+
CosmeticBr,
42+
CosmeticCar,
43+
CosmeticInstrument,
44+
CosmeticLegoKit,
45+
CosmeticTrack,
46+
VariantBean,
47+
VariantLego,
48+
)
4149
from .creator_code import CreatorCode
4250
from .enums import *
4351
from .errors import BetaAccessNotEnabled, BetaUnknownException, MissingAPIKey

fortnite_api/cosmetics/track.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ def __init__(self, *, data: dict[str, Any], http: HTTPClientT) -> None:
152152
self.bpm: int = data['bpm']
153153
self.duration: int = data['duration']
154154

155-
self.difficulty: CosmeticTrackDifficulty[HTTPClientT] = CosmeticTrackDifficulty(data=data['difficulty'], http=http)
155+
self.difficulty: CosmeticTrackDifficulty[HTTPClientT] = CosmeticTrackDifficulty(
156+
data=data['difficulty'], http=http
157+
)
156158
self.gameplay_tags: list[str] = get_with_fallback(data, 'gameplayTags', list)
157159
self.genres: list[str] = get_with_fallback(data, 'genres', list)
158160
self.album_art: Asset[HTTPClientT] = Asset(http=http, url=data['albumArt'])

fortnite_api/cosmetics/variants/bean.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ def fetch_cosmetic_br(
8989
) -> Coroutine[Any, Any, CosmeticBr]: ...
9090

9191
@overload
92-
def fetch_cosmetic_br(self: VariantBean[SyncHTTPClient], *, language: Optional[GameLanguage] = None) -> CosmeticBr: ...
92+
def fetch_cosmetic_br(
93+
self: VariantBean[SyncHTTPClient], *, language: Optional[GameLanguage] = None
94+
) -> CosmeticBr: ...
9395

9496
def fetch_cosmetic_br(
9597
self, *, language: Optional[GameLanguage] = None

fortnite_api/cosmetics/variants/lego.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ def fetch_cosmetic_br(
8787
) -> Coroutine[Any, Any, CosmeticBr]: ...
8888

8989
@overload
90-
def fetch_cosmetic_br(self: VariantLego[SyncHTTPClient], *, language: Optional[GameLanguage] = None) -> CosmeticBr: ...
90+
def fetch_cosmetic_br(
91+
self: VariantLego[SyncHTTPClient], *, language: Optional[GameLanguage] = None
92+
) -> CosmeticBr: ...
9193

9294
def fetch_cosmetic_br(
9395
self, *, language: Optional[GameLanguage] = None

fortnite_api/http.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,10 @@ def key(self) -> str:
8989

9090

9191
class HTTPMixin(abc.ABC):
92-
9392
def __init__(self, *, token: Optional[str] = None) -> None:
9493
self.token: Optional[str] = token
9594

96-
self.user_agent = 'FortniteApi (https://github.com/Fortnite-API/py-wrapper {0}) Python/{1[0]}.{1[1]}'.format(
95+
self.user_agent = 'FortniteApi (https://github.com/Fortnite-API/py-wrapper {0}) Python/{1[0]}.{1[1]}'.format( # noqa: UP032
9796
__version__, sys.version_info
9897
)
9998

0 commit comments

Comments
 (0)