Skip to content

Commit

Permalink
Merge pull request #65 from kjsanger/chore/minor-fixes
Browse files Browse the repository at this point in the history
Remove variable assignments that are never used
  • Loading branch information
mgcam authored Jun 26, 2024
2 parents 21c0add + 7b3d42a commit afc56b1
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/npg_porch/auth/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async def validate(
):

token = creds.credentials
p = None

try:
p = await validator.token2permission(token)
except CredentialsValidationException as e:
Expand Down
2 changes: 0 additions & 2 deletions src/npg_porch/db/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ async def token2permission(self, token: str):
'Token failed character validation'
)

valid_token_row = None
try:
# Using 'outerjoin' to get the left join for token, pipeline.
# We need to retrieve all token rows, regardless of whether
Expand All @@ -74,7 +73,6 @@ async def token2permission(self, token: str):
if (valid_token_row is not None) and (valid_token_row.date_revoked is not None):
raise CredentialsValidationException('A revoked token is used')

permission = None
pipeline = valid_token_row.pipeline
token_id = valid_token_row.token_id
if pipeline is None:
Expand Down
1 change: 0 additions & 1 deletion src/npg_porch/db/data_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ async def get_all_pipelines(
uri: str | None = None,
version: str | None = None
) -> list[Pipeline]:
pipelines = []
pipelines = await self._get_pipeline_db_objects(uri=uri, version=version)
return [pipe.convert_to_model() for pipe in pipelines]

Expand Down
1 change: 0 additions & 1 deletion src/npg_porch/endpoints/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ async def create_pipeline(
logging.error(f"Role {RolesEnum.POWER_USER} is required")
raise HTTPException(status_code=403)

new_pipeline = None
try:
new_pipeline = await db_accessor.create_pipeline(pipeline)
except IntegrityError as e:
Expand Down
4 changes: 2 additions & 2 deletions src/npg_porch/endpoints/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async def create_task(
) -> Task:

_validate_request(permission, task.pipeline)
created_task = None

try:
created_task = await db_accessor.create_task(
token_id=permission.requestor_id,
Expand Down Expand Up @@ -137,7 +137,7 @@ async def update_task(
) -> Task:

_validate_request(permission, task.pipeline)
changed_task = None

try:
changed_task = await db_accessor.update_task(
token_id=permission.requestor_id,
Expand Down
6 changes: 3 additions & 3 deletions tests/data_access_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async def test_get_pipeline(db_accessor):
db_accessor.get_pipeline_by_name()

with pytest.raises(NoResultFound):
pipeline = await db_accessor.get_pipeline_by_name('not here')
await db_accessor.get_pipeline_by_name('not here')

pipeline = await db_accessor.get_pipeline_by_name('ptest one')
assert pipeline
Expand Down Expand Up @@ -76,7 +76,7 @@ async def test_create_pipeline(db_accessor):
assert saved_pipeline.uri == pipeline.uri

with pytest.raises(AssertionError):
saved_pipeline = await db_accessor.create_pipeline({})
await db_accessor.create_pipeline({})
with pytest.raises(IntegrityError) as exception:
# Making duplicate provides a useful error
await db_accessor.create_pipeline(pipeline)
Expand Down Expand Up @@ -125,7 +125,7 @@ async def test_claim_tasks(db_accessor):
pipeline = give_me_a_pipeline()

with pytest.raises(NoResultFound) as exception:
tasks = await db_accessor.claim_tasks(1, pipeline)
await db_accessor.claim_tasks(1, pipeline)

assert exception.value == 'Pipeline not found'

Expand Down

0 comments on commit afc56b1

Please sign in to comment.