Skip to content

Commit

Permalink
chore: add ruff and remove pyupgrade, isort, autoflake, and `…
Browse files Browse the repository at this point in the history
…black`
  • Loading branch information
evansims committed Jan 28, 2025
1 parent 28945cb commit 24d73b5
Show file tree
Hide file tree
Showing 174 changed files with 1,752 additions and 1,225 deletions.
20 changes: 4 additions & 16 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,16 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
**/setup.cfg
**/pyproject.toml
**/requirements*.txt
**/test-requirements*.txt
- name: Install dependencies
run: pip install -r test-requirements.txt --upgrade pip

- if: matrix.python-version == '3.10'
name: Run Flake8
run: flake8 . --count --show-source --statistics

- if: matrix.python-version == '3.10'
name: Run Black
run: black . --check

- if: matrix.python-version == '3.10'
name: Run isort
run: isort . --profile black --diff --check-only

- if: matrix.python-version == '3.10'
name: Run autoflake
run: autoflake --exclude=__init__.py --remove-unused-variables --remove-all-unused-imports --quiet --check-diff --recursive .
name: Run `ruff`
run: ruff check

- name: Run tests and collect coverage
run: pytest --cov-fail-under 60 --cov openfga_sdk
Expand Down Expand Up @@ -84,7 +72,7 @@ jobs:
python-version: "3.10"
cache: "pip"
cache-dependency-path: |
**/setup.cfg
**/pyproject.toml
**/requirements*.txt
**/test-requirements*.txt
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ venv/
.venv/
.python-version
.pytest_cache
.ruff_cache
test/__pycache__/

# Translations
Expand Down
1 change: 1 addition & 0 deletions .openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ test/*
.gitlab-ci.yml
.travis.yml
tox.ini
setup.cfg
2 changes: 1 addition & 1 deletion .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ openfga_sdk/telemetry/metrics.py
openfga_sdk/telemetry/telemetry.py
openfga_sdk/telemetry/utilities.py
openfga_sdk/validation.py
pyproject.toml
requirements.txt
setup.cfg
setup.py
test-requirements.txt
test/_/configuration_test.py
Expand Down
14 changes: 14 additions & 0 deletions example/example1/example1.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# ruff: noqa: E402

"""
Python SDK for OpenFGA
API version: 1.x
Website: https://openfga.dev
Documentation: https://openfga.dev/docs
Support: https://openfga.dev/community
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
"""

import asyncio
import os
import sys
Expand Down
14 changes: 7 additions & 7 deletions example/example1/setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""
Python SDK for OpenFGA
Python SDK for OpenFGA
API version: 0.1
Website: https://openfga.dev
Documentation: https://openfga.dev/docs
Support: https://discord.gg/8naAwJfWN6
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
API version: 1.x
Website: https://openfga.dev
Documentation: https://openfga.dev/docs
Support: https://openfga.dev/community
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
"""

from setuptools import find_packages, setup
Expand Down
25 changes: 19 additions & 6 deletions example/opentelemetry/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# ruff: noqa: E402

"""
Python SDK for OpenFGA
API version: 1.x
Website: https://openfga.dev
Documentation: https://openfga.dev/docs
Support: https://openfga.dev/community
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
"""

import asyncio
import os
import sys
Expand Down Expand Up @@ -199,16 +213,15 @@ async def main():
print(f"Making {checks_requests} checks ...", end=" ")
for _ in range(checks_requests):
try:
allowed = app().unpack(
await fga_client.check(
body=ClientCheckRequest(
user="user:anne", relation="owner", object="folder:foo"
),
await fga_client.check(
body=ClientCheckRequest(
user="user:anne", relation="owner", object="folder:foo"
),
"allowed",
)

except FgaValidationException as error:
print(f"Checked failed due to validation exception: {error}")

print("Done!")


Expand Down
14 changes: 7 additions & 7 deletions example/opentelemetry/setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""
Python SDK for OpenFGA
Python SDK for OpenFGA
API version: 0.1
Website: https://openfga.dev
Documentation: https://openfga.dev/docs
Support: https://discord.gg/8naAwJfWN6
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
API version: 1.x
Website: https://openfga.dev
Documentation: https://openfga.dev/docs
Support: https://openfga.dev/community
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
"""

from setuptools import find_packages, setup
Expand Down
18 changes: 16 additions & 2 deletions example/streamed-list-objects/asynchronous.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# ruff: noqa: E402

"""
Python SDK for OpenFGA
API version: 1.x
Website: https://openfga.dev
Documentation: https://openfga.dev/docs
Support: https://openfga.dev/community
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
"""

import asyncio
import json
import os
Expand Down Expand Up @@ -72,7 +86,7 @@ async def main():
)
print(f"Created temporary authorization model ({model})")

print(f"Writing 100 mock tuples to store.")
print("Writing 100 mock tuples to store.")

# Write mock data
writes = []
Expand Down Expand Up @@ -111,7 +125,7 @@ async def main():
try:
await fga_client.delete_store()
print(f"Deleted temporary store ({store})")
except:
except Exception:
pass

print("Finished.")
Expand Down
14 changes: 7 additions & 7 deletions example/streamed-list-objects/setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""
Python SDK for OpenFGA
Python SDK for OpenFGA
API version: 0.1
Website: https://openfga.dev
Documentation: https://openfga.dev/docs
Support: https://discord.gg/8naAwJfWN6
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
API version: 1.x
Website: https://openfga.dev
Documentation: https://openfga.dev/docs
Support: https://openfga.dev/community
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
"""

from setuptools import find_packages, setup
Expand Down
18 changes: 16 additions & 2 deletions example/streamed-list-objects/synchronous.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# ruff: noqa: E402

"""
Python SDK for OpenFGA
API version: 1.x
Website: https://openfga.dev
Documentation: https://openfga.dev/docs
Support: https://openfga.dev/community
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
"""

import json
import os
import sys
Expand Down Expand Up @@ -69,7 +83,7 @@ def main():
)
print(f"Created temporary authorization model ({model})")

print(f"Writing 100 mock tuples to store.")
print("Writing 100 mock tuples to store.")

# Write mock data
writes = []
Expand Down Expand Up @@ -108,7 +122,7 @@ def main():
try:
fga_client.delete_store()
print(f"Deleted temporary store ({store})")
except:
except Exception:
pass

print("Finished.")
Expand Down
Loading

0 comments on commit 24d73b5

Please sign in to comment.