Skip to content

Commit

Permalink
Use "a or b" not "a if a else b"
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Jul 24, 2023
1 parent aa637db commit 3c84fee
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions python/lsst/daf/butler/script/exportCalibs.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ def exportCalibs(
"""
butler = Butler(repo, writeable=False)

dataset_type_query = dataset_type if dataset_type else ...
collections_query = collections if collections else ...
dataset_type_query = dataset_type or ...
collections_query = collections or ...

Check warning on line 122 in python/lsst/daf/butler/script/exportCalibs.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/daf/butler/script/exportCalibs.py#L121-L122

Added lines #L121 - L122 were not covered by tests

calibTypes = [
datasetType
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/script/queryDataIds.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def queryDataIds(

query_collections: Iterable[str] | EllipsisType | None = None
if datasets:
query_collections = collections if collections else ...
query_collections = collections or ...
results = butler.registry.queryDataIds(
dimensions, datasets=datasets, where=where, collections=query_collections
)
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/script/queryDatasetTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def queryDatasetTypes(repo: str, verbose: bool, glob: Iterable[str], components:
collection names.
"""
butler = Butler(repo, without_datastore=True)
expression = glob if glob else ...
expression = glob or ...
datasetTypes = butler.registry.queryDatasetTypes(components=components, expression=expression)
if verbose:
table = Table(
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/daf/butler/script/queryDatasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ def __init__(
def _getDatasets(
self, glob: Iterable[str], collections: Iterable[str], where: str, find_first: bool
) -> None:
datasetTypes = glob if glob else ...
query_collections: Iterable[str] | EllipsisType = collections if collections else ...
datasetTypes = glob or ...
query_collections: Iterable[str] | EllipsisType = collections or ...

self.datasets = self.butler.registry.queryDatasets(
datasetType=datasetTypes, collections=query_collections, where=where, findFirst=find_first
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/script/queryDimensionRecords.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def queryDimensionRecords(

query_collections: Iterable[str] | EllipsisType | None = None
if datasets:
query_collections = collections if collections else ...
query_collections = collections or ...
query_results = butler.registry.queryDimensionRecords(
element, datasets=datasets, collections=query_collections, where=where, check=not no_check
)
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/daf/butler/script/retrieveArtifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def retrieveArtifacts(
transferred : `list` of `lsst.resources.ResourcePath`
The destination URIs of every transferred artifact.
"""
query_types = dataset_type if dataset_type else ...
query_collections: tuple[str, ...] | EllipsisType = collections if collections else ...
query_types = dataset_type or ...
query_collections: tuple[str, ...] | EllipsisType = collections or ...

butler = Butler(repo, writeable=False)

Expand Down
4 changes: 2 additions & 2 deletions python/lsst/daf/butler/script/transferDatasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def transferDatasets(
source_butler = Butler(source, writeable=False)
dest_butler = Butler(dest, writeable=True)

dataset_type_expr = dataset_type if dataset_type else ...
collections_expr: tuple[str, ...] | EllipsisType = collections if collections else ...
dataset_type_expr = dataset_type or ...
collections_expr: tuple[str, ...] | EllipsisType = collections or ...

Check warning on line 75 in python/lsst/daf/butler/script/transferDatasets.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/daf/butler/script/transferDatasets.py#L74-L75

Added lines #L74 - L75 were not covered by tests

source_refs = source_butler.registry.queryDatasets(
datasetType=dataset_type_expr, collections=collections_expr, where=where, findFirst=find_first
Expand Down

0 comments on commit 3c84fee

Please sign in to comment.