Skip to content

Commit 2ec56b1

Browse files
committed
chore: add ruff linter and code formatter
1 parent 28945cb commit 2ec56b1

File tree

174 files changed

+1775
-1187
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+1775
-1187
lines changed

.github/workflows/main.yaml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,16 @@ jobs:
3131
python-version: ${{ matrix.python-version }}
3232
cache: "pip"
3333
cache-dependency-path: |
34-
**/setup.cfg
34+
**/pyproject.toml
3535
**/requirements*.txt
3636
**/test-requirements*.txt
3737
3838
- name: Install dependencies
3939
run: pip install -r test-requirements.txt --upgrade pip
4040

4141
- if: matrix.python-version == '3.10'
42-
name: Run Flake8
43-
run: flake8 . --count --show-source --statistics
44-
45-
- if: matrix.python-version == '3.10'
46-
name: Run Black
47-
run: black . --check
48-
49-
- if: matrix.python-version == '3.10'
50-
name: Run isort
51-
run: isort . --profile black --diff --check-only
52-
53-
- if: matrix.python-version == '3.10'
54-
name: Run autoflake
55-
run: autoflake --exclude=__init__.py --remove-unused-variables --remove-all-unused-imports --quiet --check-diff --recursive .
42+
name: Run `ruff`
43+
run: ruff check
5644

5745
- name: Run tests and collect coverage
5846
run: pytest --cov-fail-under 60 --cov openfga_sdk
@@ -84,7 +72,7 @@ jobs:
8472
python-version: "3.10"
8573
cache: "pip"
8674
cache-dependency-path: |
87-
**/setup.cfg
75+
**/pyproject.toml
8876
**/requirements*.txt
8977
**/test-requirements*.txt
9078

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ venv/
5050
.venv/
5151
.python-version
5252
.pytest_cache
53+
.ruff_cache
5354
test/__pycache__/
5455

5556
# Translations

.openapi-generator-ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ test/*
1414
.gitlab-ci.yml
1515
.travis.yml
1616
tox.ini
17+
setup.cfg

.openapi-generator/FILES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ openfga_sdk/telemetry/metrics.py
260260
openfga_sdk/telemetry/telemetry.py
261261
openfga_sdk/telemetry/utilities.py
262262
openfga_sdk/validation.py
263+
pyproject.toml
263264
requirements.txt
264-
setup.cfg
265265
setup.py
266266
test-requirements.txt
267267
test/_/configuration_test.py

example/example1/example1.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1+
# ruff: noqa: E402
2+
3+
"""
4+
Python SDK for OpenFGA
5+
6+
API version: 1.x
7+
Website: https://openfga.dev
8+
Documentation: https://openfga.dev/docs
9+
Support: https://openfga.dev/community
10+
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
11+
12+
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
13+
"""
14+
115
import asyncio
216
import os
317
import sys
418
import uuid
519

620
from dotenv import load_dotenv
721

22+
823
sdk_path = os.path.realpath(os.path.join(os.path.abspath(__file__), "..", "..", ".."))
924
sys.path.insert(0, sdk_path)
1025

example/example1/setup.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
"""
2-
Python SDK for OpenFGA
2+
Python SDK for OpenFGA
33
4-
API version: 0.1
5-
Website: https://openfga.dev
6-
Documentation: https://openfga.dev/docs
7-
Support: https://discord.gg/8naAwJfWN6
8-
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
4+
API version: 1.x
5+
Website: https://openfga.dev
6+
Documentation: https://openfga.dev/docs
7+
Support: https://openfga.dev/community
8+
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
99
10-
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
10+
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
1111
"""
1212

1313
from setuptools import find_packages, setup
1414

15+
1516
NAME = "example1"
1617
VERSION = "0.0.1"
1718
REQUIRES = ["openfga-sdk >= 0.9.1"]

example/opentelemetry/main.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1+
# ruff: noqa: E402
2+
3+
"""
4+
Python SDK for OpenFGA
5+
6+
API version: 1.x
7+
Website: https://openfga.dev
8+
Documentation: https://openfga.dev/docs
9+
Support: https://openfga.dev/community
10+
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
11+
12+
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
13+
"""
14+
115
import asyncio
216
import os
317
import sys
18+
419
from operator import attrgetter
520
from random import randint
621
from typing import Any
@@ -15,6 +30,7 @@
1530
)
1631
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
1732

33+
1834
# For usage convenience of this example, we will import the OpenFGA SDK from the parent directory.
1935
sdk_path = os.path.realpath(os.path.join(os.path.abspath(__file__), "..", "..", ".."))
2036
sys.path.insert(0, sdk_path)
@@ -199,16 +215,15 @@ async def main():
199215
print(f"Making {checks_requests} checks ...", end=" ")
200216
for _ in range(checks_requests):
201217
try:
202-
allowed = app().unpack(
203-
await fga_client.check(
204-
body=ClientCheckRequest(
205-
user="user:anne", relation="owner", object="folder:foo"
206-
),
218+
await fga_client.check(
219+
body=ClientCheckRequest(
220+
user="user:anne", relation="owner", object="folder:foo"
207221
),
208-
"allowed",
209222
)
223+
210224
except FgaValidationException as error:
211225
print(f"Checked failed due to validation exception: {error}")
226+
212227
print("Done!")
213228

214229

example/opentelemetry/setup.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
"""
2-
Python SDK for OpenFGA
2+
Python SDK for OpenFGA
33
4-
API version: 0.1
5-
Website: https://openfga.dev
6-
Documentation: https://openfga.dev/docs
7-
Support: https://discord.gg/8naAwJfWN6
8-
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
4+
API version: 1.x
5+
Website: https://openfga.dev
6+
Documentation: https://openfga.dev/docs
7+
Support: https://openfga.dev/community
8+
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
99
10-
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
10+
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
1111
"""
1212

1313
from setuptools import find_packages, setup
1414

15+
1516
NAME = "openfga-opentelemetry-example"
1617
VERSION = "0.0.1"
1718
REQUIRES = [""]

example/streamed-list-objects/asynchronous.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
1+
# ruff: noqa: E402
2+
3+
"""
4+
Python SDK for OpenFGA
5+
6+
API version: 1.x
7+
Website: https://openfga.dev
8+
Documentation: https://openfga.dev/docs
9+
Support: https://openfga.dev/community
10+
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
11+
12+
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
13+
"""
14+
115
import asyncio
216
import json
317
import os
418
import sys
19+
520
from operator import attrgetter
621
from typing import Any
722

823
from dotenv import load_dotenv
924

25+
1026
sdk_path = os.path.realpath(os.path.join(os.path.abspath(__file__), "..", "..", ".."))
1127
sys.path.insert(0, sdk_path)
1228

@@ -72,7 +88,7 @@ async def main():
7288
)
7389
print(f"Created temporary authorization model ({model})")
7490

75-
print(f"Writing 100 mock tuples to store.")
91+
print("Writing 100 mock tuples to store.")
7692

7793
# Write mock data
7894
writes = []
@@ -111,7 +127,7 @@ async def main():
111127
try:
112128
await fga_client.delete_store()
113129
print(f"Deleted temporary store ({store})")
114-
except:
130+
except Exception:
115131
pass
116132

117133
print("Finished.")

example/streamed-list-objects/setup.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
"""
2-
Python SDK for OpenFGA
2+
Python SDK for OpenFGA
33
4-
API version: 0.1
5-
Website: https://openfga.dev
6-
Documentation: https://openfga.dev/docs
7-
Support: https://discord.gg/8naAwJfWN6
8-
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
4+
API version: 1.x
5+
Website: https://openfga.dev
6+
Documentation: https://openfga.dev/docs
7+
Support: https://openfga.dev/community
8+
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
99
10-
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
10+
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
1111
"""
1212

1313
from setuptools import find_packages, setup
1414

15+
1516
NAME = "openfga-streamed-list-objects-example"
1617
VERSION = "0.0.1"
1718
REQUIRES = [""]

0 commit comments

Comments
 (0)