Skip to content

Commit 0f49feb

Browse files
committed
chore: add and run linting with ruff and deptry
1 parent c11e571 commit 0f49feb

29 files changed

Lines changed: 268 additions & 388 deletions

.pre-commit-config.yaml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1-
exclude_types:
2-
- makefile
3-
- toml
4-
- yaml
5-
- json
6-
- markdown
7-
- ini
8-
91
repos:
10-
- repo: https://github.com/psf/black
11-
rev: 22.3.0
12-
hooks:
13-
- id: black
14-
15-
- repo: https://github.com/PyCQA/flake8
16-
rev: 7.3.0
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.6.3
175
hooks:
18-
- id: flake8
6+
# Run the linter.
7+
- id: ruff
8+
# Run the formatter.
9+
- id: ruff-format
1910

2011
- repo: https://github.com/pre-commit/pre-commit-hooks
2112
rev: v2.3.0

justfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ install:
55
poetry install
66
poetry run pre-commit install
77

8+
lint:
9+
poetry run ruff check
10+
poetry run ruff format --check
11+
poetry run deptry .
12+
13+
format:
14+
poetry run ruff format
15+
poetry run ruff check --fix
16+
817
test *flags:
918
poetry run pytest --cov=stacklet tests {{ flags }}
1019

poetry.lock

Lines changed: 171 additions & 247 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,30 @@ click = "^8.0.1"
2323
requests = "^2.32.4"
2424
jsonschema = "^4.9.0"
2525
PyYAML = "^6.0"
26-
pyaml = "^21.10.1"
2726
PyJWT = "^2.4.0"
2827
boto3 = "^1.39.16"
29-
certifi = "2024.8.30"
28+
charset_normalizer = "^3.4.2"
29+
jmespath = "^1.0.1"
3030

3131
[tool.poetry.group.dev.dependencies]
32-
flake8 = "^3.9.0"
33-
black = "^25.1.0"
34-
isort = "^5.8.0"
32+
ruff = "^0.12.7"
3533
moto = { version = "^5.1.9", extras = ["cognitoidp"] }
3634
pytest = "^8.4"
3735
pytest-cov = "^6.2.1"
3836
requests-mock = "^1.8.0"
3937
pre-commit = "^2.12.0"
4038
Nuitka = "^2.7.12"
41-
zstandard = "^0.15.2"
4239
semver = "^2.13.0"
4340
toml = "^0.10.2"
41+
deptry = "^0.23.1"
42+
43+
[tool.ruff]
44+
line-length = 100
45+
46+
[tool.ruff.lint]
47+
# Add `line-too-long` and isort to the enforced rule set.
48+
extend-select = ["E501", "I", "F"]
49+
50+
[tool.deptry]
51+
known_first_party = ["stacklet"]
52+
per_rule_ignores = { "DEP004" = ["toml", "semver"] }

scripts/upgrade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import sys
55

66
import click
7+
import semver
78

89
# in python 3.11 we should switch out to tomllib
910
import toml
10-
import semver
1111

1212

1313
@click.group()

stacklet/client/platform/cli.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import json
55
import os
66
import pathlib
7-
87
from urllib.parse import urlsplit, urlunsplit
8+
99
import click
1010
import jwt
1111
import requests
@@ -88,9 +88,7 @@ def cli(*args, **kwargs):
8888
@click.option("--idp-id", prompt="(SSO) IDP ID", default="")
8989
@click.option("--auth-url", prompt="(SSO) Auth Url", default="")
9090
@click.option("--cubejs", prompt="Stacklet cube.js endpoint", default="")
91-
@click.option(
92-
"--location", prompt="Config File Location", default="~/.stacklet/config.json"
93-
) # noqa
91+
@click.option("--location", prompt="Config File Location", default="~/.stacklet/config.json") # noqa
9492
@click.pass_context
9593
def configure(
9694
ctx,
@@ -316,12 +314,8 @@ def login(ctx, username, password):
316314
if not os.path.exists(
317315
os.path.dirname(os.path.expanduser(StackletContext.DEFAULT_CREDENTIALS))
318316
):
319-
os.makedirs(
320-
os.path.dirname(os.path.expanduser(StackletContext.DEFAULT_CREDENTIALS))
321-
)
322-
with open(
323-
os.path.expanduser(StackletContext.DEFAULT_CREDENTIALS), "w+"
324-
) as f: # noqa
317+
os.makedirs(os.path.dirname(os.path.expanduser(StackletContext.DEFAULT_CREDENTIALS)))
318+
with open(os.path.expanduser(StackletContext.DEFAULT_CREDENTIALS), "w+") as f: # noqa
325319
f.write(res)
326320

327321

stacklet/client/platform/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
# platform client using cli
55

6-
import jmespath
76
from pathlib import Path
87

9-
from stacklet.client.platform.executor import StackletGraphqlExecutor
10-
from stacklet.client.platform.context import StackletContext
11-
from stacklet.client.platform.utils import get_token, _PAGINATION_OPTIONS
8+
import jmespath
129

1310
# import the commands so the registry is populated when the client is instantiated
1411
import stacklet.client.platform.commands # noqa
12+
from stacklet.client.platform.context import StackletContext
13+
from stacklet.client.platform.executor import StackletGraphqlExecutor
14+
from stacklet.client.platform.utils import _PAGINATION_OPTIONS, get_token
1515

1616

1717
def platform_client(pager=False, expr=False):

stacklet/client/platform/cognito.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ def create_user(self, user, password, email, phone_number, permanent=True):
6161
return True
6262

6363
# update the password so it's set permantently
64-
self.log.debug(
65-
"Resetting admin password to disable temporary password for %s" % user
66-
)
64+
self.log.debug("Resetting admin password to disable temporary password for %s" % user)
6765
res = self.client.admin_set_user_password(
6866
UserPoolId=self.user_pool_id,
6967
Username=user,

stacklet/client/platform/commands/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from .account import account
55
from .accountgroup import account_group
66
from .binding import binding
7-
from .graphql import graphql
87
from .cube import cubejs
8+
from .graphql import graphql
99
from .policy import policy
1010
from .policycollection import policy_collection
1111
from .repository import repository

stacklet/client/platform/commands/account.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Copyright Stacklet, Inc.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
import click
54
import json
65

7-
from stacklet.client.platform.executor import _run_graphql
8-
from stacklet.client.platform.executor import StackletGraphqlExecutor, snippet_options
6+
import click
7+
8+
from stacklet.client.platform.executor import StackletGraphqlExecutor, _run_graphql, snippet_options
99
from stacklet.client.platform.graphql import StackletGraphqlSnippet
1010
from stacklet.client.platform.utils import click_group_entry, default_options
1111

0 commit comments

Comments
 (0)