Skip to content

Commit ef330e8

Browse files
authored
ci: switch from black/isort to ruff (#37)
* ci: switch from black/isort to ruff * fix: resolve ruff linting errors * style: reformat with ruff
1 parent 9976a6f commit ef330e8

13 files changed

Lines changed: 30 additions & 30 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
16+
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13"]
1717

1818
steps:
1919
- uses: actions/checkout@v3
@@ -26,13 +26,12 @@ jobs:
2626
cache-dependency-path: pyproject.toml
2727

2828
- name: Install (including dev dependencies)
29-
run: pip install .[aws,azure,dev]
29+
run: pip install .[aws,azure,dev] ruff
3030

31-
- name: Lint with flake8
32-
run: flake8 . --count --show-source --statistics
31+
- name: Lint and check formatting with Ruff
32+
run: |
33+
ruff check --extend-select I .
34+
ruff format --check .
3335
3436
- name: Test with pytest
3537
run: pytest
36-
37-
- name: Validate formatting with black
38-
run: black --check --diff .

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[![ci](https://github.com/fidelity/awsrun/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fidelity/awsrun/actions/workflows/ci.yml)
2-
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
2+
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
33

44
# awsrun & azurerun
55

src/awsrun/acctload.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,6 @@ def __init__(
10611061
no_verify=False,
10621062
cache_path=None,
10631063
):
1064-
10651064
session = requests.Session()
10661065
session.mount("file://", FileAdapter())
10671066

@@ -1132,7 +1131,7 @@ def __eq__(self, other):
11321131

11331132
def __repr__(self):
11341133
pairs = (f"{k}={repr(v)}" for k, v in self._attrs.items())
1135-
return f'Account({", ".join(pairs)})'
1134+
return f"Account({', '.join(pairs)})"
11361135

11371136
def __str__(self):
11381137
if not self._str_template:
@@ -1151,7 +1150,7 @@ class AccountsNotFoundError(Exception):
11511150

11521151
def __init__(self, missing_acct_ids):
11531152
self.missing_acct_ids = missing_acct_ids
1154-
super().__init__(f'Account IDs not found: {", ".join(missing_acct_ids)}')
1153+
super().__init__(f"Account IDs not found: {', '.join(missing_acct_ids)}")
11551154

11561155

11571156
class InvalidFormatTemplateError(Exception):

src/awsrun/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ def _print_valid_commands(commands, out=sys.stdout):
11161116
def _print_accounts(accts, out=sys.stdout):
11171117
"""Print the list of accounts."""
11181118
count = len(accts)
1119-
print(f'{count} account{"s" if count != 1 else ""} selected:\n', file=out)
1119+
print(f"{count} account{'s' if count != 1 else ''} selected:\n", file=out)
11201120
print(", ".join(str(a) for a in accts), file=out, end="\n\n")
11211121

11221122

@@ -1125,7 +1125,7 @@ def _ask_for_confirmation(accts):
11251125
_print_accounts(accts, out=sys.stderr)
11261126
print("Proceed (y/n)? ", flush=True, end="", file=sys.stderr)
11271127
answer = input()
1128-
if not answer.lower() in ["y", "yes"]:
1128+
if answer.lower() not in ["y", "yes"]:
11291129
print("Exiting", file=sys.stderr)
11301130
sys.exit(0)
11311131

src/awsrun/commands/aws/list_igws.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def regional_execute(self, session, acct, region):
6767
file=out,
6868
)
6969
if attachments:
70-
print(f' vpcs={", ".join(attachments)}', end="", file=out)
70+
print(f" vpcs={', '.join(attachments)}", end="", file=out)
7171

7272
print(file=out)
7373

src/awsrun/commands/aws/list_lambdas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def regional_execute(self, session, acct, region):
9393
by_role[fn["Role"]].append(fn)
9494
continue
9595
print(
96-
f'{acct}/{region}: name={fn["FunctionName"]} runtime={fn["Runtime"]} role={fn["Role"]} public={_is_public(fn)}',
96+
f"{acct}/{region}: name={fn['FunctionName']} runtime={fn['Runtime']} role={fn['Role']} public={_is_public(fn)}",
9797
file=out,
9898
)
9999

src/awsrun/commands/aws/list_public_ips.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def regional_execute(self, session, acct, region):
7676
# are processing.
7777
for (vpc_id, owner_id), ips in public_ips.items():
7878
print(
79-
f'{acct}/{region}: id={vpc_id} owner={owner_id} ips={", ".join(ips)}',
79+
f"{acct}/{region}: id={vpc_id} owner={owner_id} ips={', '.join(ips)}",
8080
file=out,
8181
)
8282

src/awsrun/plugins/accts/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,6 @@ def instantiate(self, args):
896896

897897
# Check and set auth options if using authentication.
898898
if args.loader_auth != "none":
899-
900899
# Command line flags take priority
901900
if args.loader_username:
902901
auth_options["username"] = args.loader_username

src/awsrun/plugins/accts/azure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
: `AzureCLI` loads subscriptions and metadata for those subscriptions via the
2121
Azure CLI `az account list --all` command.
2222
"""
23+
2324
import logging
2425

2526
from awsrun.acctload import AzureCLIAccountLoader
2627
from awsrun.plugmgr import Plugin
2728

28-
2929
LOG = logging.getLogger(__name__)
3030

3131

src/awsrun/plugmgr.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
`PluginManager.parse_args` as it will be called by `PluginManager.instantiate`
6767
if it was not already.
6868
"""
69+
6970
import importlib
7071
import logging
7172
from contextlib import suppress

0 commit comments

Comments
 (0)