Skip to content

Commit

Permalink
Fix FBT001 Boolean-typed positional argument in function definition
Browse files Browse the repository at this point in the history
This explicitly expects Django signals and Click options to
be called with keyword arguments.
  • Loading branch information
brianhelba committed Dec 1, 2023
1 parent 7894e90 commit e970122
Show file tree
Hide file tree
Showing 17 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion dandiapi/api/asset_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def extract_paths(path: str) -> list[str]:
return nodepaths


def get_root_paths_many(versions: QuerySet[Version], join_assets=False) -> QuerySet[AssetPath]:
def get_root_paths_many(versions: QuerySet[Version], *, join_assets=False) -> QuerySet[AssetPath]:
"""Return all root paths for all provided versions."""
qs = AssetPath.objects.get_queryset()

Expand Down
2 changes: 1 addition & 1 deletion dandiapi/api/management/commands/cleanup_blobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def s3_client():

@click.command()
@click.option('--delete', is_flag=True, default=False)
def cleanup_blobs(delete: bool):
def cleanup_blobs(*, delete: bool):
client = s3_client()
# Ignore pagination for now, hopefully there aren't enough objects to matter
objs = client.list_object_versions(Bucket=BUCKET, Prefix='dev/')
Expand Down
2 changes: 1 addition & 1 deletion dandiapi/api/management/commands/collect_garbage.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def echo_report():
@click.option('--assetblobs', is_flag=True, default=False, help='Delete AssetBlobs')
@click.option('--uploads', is_flag=True, default=False, help='Delete Uploads')
@click.option('--s3blobs', is_flag=True, default=False, help='Delete S3 Blobs')
def collect_garbage(assets: bool, assetblobs: bool, uploads: bool, s3blobs: bool):
def collect_garbage(*, assets: bool, assetblobs: bool, uploads: bool, s3blobs: bool):
"""Manually run garbage collection on the database."""
# Log how many things there are before deleting them
doing_deletes = assets or assetblobs or uploads or s3blobs
Expand Down
2 changes: 1 addition & 1 deletion dandiapi/api/management/commands/create_dev_dandiset.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@click.command()
@click.option('--name', default='Development Dandiset')
@click.option('--owner', 'email', required=True, help='The email address of the owner')
def create_dev_dandiset(name: str, email: str):
def create_dev_dandiset(*, name: str, email: str):
owner = User.objects.get(email=email)

version_metadata = {
Expand Down
2 changes: 1 addition & 1 deletion dandiapi/api/management/commands/depose_placeholder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@click.command()
@click.argument('placeholder_email')
@click.argument('github_email')
def depose_placeholder(placeholder_email: str, github_email: str):
def depose_placeholder(*, placeholder_email: str, github_email: str):
placeholder_user = User.objects.get(email=placeholder_email)
github_user = User.objects.get(email=github_email)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@click.argument('dandiset')
@click.argument('published_version')
@click.argument('to_version')
def migrate_published_version_metadata(dandiset: str, published_version: str, to_version: str):
def migrate_published_version_metadata(*, dandiset: str, published_version: str, to_version: str):
click.echo(
f'Migrating published version {dandiset}/{published_version} metadata to version {to_version}' # noqa: E501
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@click.command()
@click.argument('to_version')
def migrate_version_metadata(to_version: str):
def migrate_version_metadata(*, to_version: str):
click.echo(f'Migrating all version metadata to version {to_version}')
for version in Version.objects.filter(version='draft'):
click.echo(f'Migrating {version.dandiset.identifier}/{version.version}')
Expand Down
2 changes: 1 addition & 1 deletion dandiapi/api/management/commands/revalidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@click.option('--versions', is_flag=True, default=False)
@click.option('--revalidate-all', is_flag=True, default=False)
@click.option('--dry-run', is_flag=True, default=False)
def revalidate(assets: bool, versions: bool, revalidate_all: bool, dry_run: bool):
def revalidate(*, assets: bool, versions: bool, revalidate_all: bool, dry_run: bool):
"""
Revalidate all Versions and Assets.
Expand Down
2 changes: 1 addition & 1 deletion dandiapi/api/services/dandiset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def create_dandiset(

embargo_status = Dandiset.EmbargoStatus.EMBARGOED if embargo else Dandiset.EmbargoStatus.OPEN
version_metadata = _normalize_version_metadata(
version_metadata, embargo, f'{user.last_name}, {user.first_name}', user.email
version_metadata, f'{user.last_name}, {user.first_name}', user.email, embargo=embargo
)

with transaction.atomic():
Expand Down
2 changes: 1 addition & 1 deletion dandiapi/api/services/version/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def _normalize_version_metadata(
raw_version_metadata: dict, embargo: bool, name: str, email: str
raw_version_metadata: dict, name: str, email: str, *, embargo: bool
) -> dict:
"""
Take raw version metadata and convert it into something suitable to be used in a formal Version.
Expand Down
6 changes: 3 additions & 3 deletions dandiapi/api/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@


@receiver(check_request_enabled, dispatch_uid='cors_allow_anyone_read_only')
def cors_allow_anyone_read_only(sender, request, **kwargs):
def cors_allow_anyone_read_only(*, sender, request, **kwargs):
"""Allow any read-only request from any origin."""
return request.method in ('GET', 'HEAD', 'OPTIONS')


@receiver(post_save, sender=settings.AUTH_USER_MODEL, dispatch_uid='create_auth_token')
def create_auth_token(sender, instance=None, created=False, **kwargs):
def create_auth_token(*, sender, instance=None, created=False, **kwargs):
"""Create an auth token for every new user."""
if created:
Token.objects.create(user=instance)


@receiver(user_signed_up)
def user_signed_up_listener(sender, user, **kwargs):
def user_signed_up_listener(*, sender, user, **kwargs):
"""Create UserMetadata whenever a user signs up."""
if settings.AUTO_APPROVE_USERS:
status = UserMetadata.Status.APPROVED
Expand Down
2 changes: 1 addition & 1 deletion dandiapi/api/user_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ def depose_placeholder(user):


@receiver(user_logged_in)
def user_log_in_listener(sender, user, **kwargs):
def user_log_in_listener(*, sender, user, **kwargs):
"""Attempt replace a placeholder user every time a real user logs in."""
depose_placeholder(user)
2 changes: 1 addition & 1 deletion dandiapi/zarr/management/commands/ingest_dandiset_zarrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
@click.command()
@click.argument('dandiset_id', type=str)
@click.option('-f', '--force', help='Force re-ingestion', is_flag=True)
def ingest_dandiset_zarrs(dandiset_id: str, **kwargs):
def ingest_dandiset_zarrs(*, dandiset_id: str, **kwargs):
_ingest_dandiset_zarrs(dandiset_id=int(dandiset_id.lstrip('0')), **kwargs)
2 changes: 1 addition & 1 deletion dandiapi/zarr/management/commands/rename_ngff.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@click.command()
@click.argument('dandiset_id', type=int, required=False)
def rename_ngff(dandiset_id: int | None):
def rename_ngff(*, dandiset_id: int | None):
"""
Change extension of all .ngff ZarrArchives (plus their associated Asset paths) to .ome.zarr.
Expand Down
2 changes: 1 addition & 1 deletion dandiapi/zarr/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


@shared_task(queue='ingest_zarr_archive', time_limit=3600)
def ingest_zarr_archive(zarr_id: str, force: bool = False):
def ingest_zarr_archive(zarr_id: str, *, force: bool = False):
# Ensure zarr is in pending state before proceeding
with transaction.atomic():
zarr: ZarrArchive = ZarrArchive.objects.select_for_update().get(zarr_id=zarr_id)
Expand Down
2 changes: 1 addition & 1 deletion scripts/delete_from_versioned_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def delete_version(bucket, thing):
@click.option('--prefix', prompt='Path to delete', help='The prefix to delete all files under')
@click.option('--force', is_flag=True, help='Skip confirmation prompts')
@click.option('--threads', prompt='Threads', default=30, help='How many threads to use')
def delete_objects(profile: str, bucket: str, prefix: str, force: bool, threads: int):
def delete_objects(*, profile: str, bucket: str, prefix: str, force: bool, threads: int):
session = boto3.Session(profile_name=profile)
s3 = session.resource('s3')
bucket = s3.Bucket(bucket)
Expand Down
2 changes: 1 addition & 1 deletion scripts/papertrail.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@click.option(
'-o', '--out', 'output_file', help='The output file', default='logs.tsv.gz', show_default=True
)
def cli(start, end, force, amend, output_file):
def cli(*, start, end, force, amend, output_file):
if PAPERTRAIL_TOKEN is None:
raise ClickException(
'Must set the PAPERTRAIL_APIKEY environment variable. '
Expand Down

0 comments on commit e970122

Please sign in to comment.