Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix/ci: updated pylint #97

Merged
merged 1 commit into from Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions connaisseur/key_store.py
Expand Up @@ -35,10 +35,10 @@ def get_key(self, key_id: str):
"""
try:
return self.keys[key_id]
except KeyError:
except KeyError as err:
raise NotFoundException(
'could not find key id "{}" in keystore.'.format(key_id)
)
) from err

def get_hash(self, role: str):
"""
Expand All @@ -48,10 +48,10 @@ def get_hash(self, role: str):
"""
try:
return self.hashes[role]
except KeyError:
except KeyError as err:
raise NotFoundException(
'could not find hash for role "{}" in keystore.'.format(role)
)
) from err

def update(self, trust_data):
"""
Expand Down
4 changes: 2 additions & 2 deletions connaisseur/mutate.py
Expand Up @@ -156,11 +156,11 @@ def validate(request: dict):
f"for resource {request_object_kind}."
)
)
except KeyError:
except KeyError as err:
raise BaseConnaisseurException(
f"unknown request object kind {request_object_kind}",
create_logging_context(request),
)
) from err


def admit(request: dict):
Expand Down
8 changes: 4 additions & 4 deletions connaisseur/notary_api.py
Expand Up @@ -140,11 +140,11 @@ def parse_auth(auth_header: str):

try:
realm = quote(params_dict.pop("realm"), safe="/:")
except KeyError:
except KeyError as err:
raise NotFoundException(
"could not find any realm in authentication header.",
{"auth_header": auth_header},
)
) from err
params = urlencode(params_dict, safe="/:")

url = f"{realm}?{params}"
Expand Down Expand Up @@ -191,10 +191,10 @@ def get_auth_token(url: str):
token = response.json()["access_token"]
else:
token = response.json()["token"]
except KeyError:
except KeyError as err:
raise NotFoundException(
"no token in authentication server response.", {"auth_url": url}
)
) from err

token_re = r"^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*$" # nosec

Expand Down
4 changes: 2 additions & 2 deletions connaisseur/policy.py
Expand Up @@ -31,8 +31,8 @@ def __init__(self):
schema = json.load(schema_file)
try:
validate(instance=image_policy, schema=schema)
except ValidationError:
raise InvalidFormatException("invalid format for image policy.")
except ValidationError as err:
raise InvalidFormatException("invalid format for image policy.") from err

self.policy = image_policy

Expand Down
20 changes: 12 additions & 8 deletions connaisseur/trust_data.py
Expand Up @@ -35,11 +35,13 @@ def __new__(cls, data: dict, role: str):

try:
return super(TrustData, cls).__new__(classes[role])
except KeyError:
except KeyError as err:
if re.match("^targets/[^/\\s]+$", role):
return super(TrustData, cls).__new__(TargetsData)

raise NoSuchClassError("could not find class with name {}.".format(role))
raise NoSuchClassError(
"could not find class with name {}.".format(role)
) from err

def __init__(self, data: dict, role: str):
self.schema_path = self.schema_path.format(role)
Expand All @@ -59,10 +61,10 @@ def _validate_schema(self, data: dict):

try:
json_validate(instance=data, schema=schema, format_checker=JFormatChecker())
except JValidationError:
except JValidationError as err:
raise ValidationError(
"trust data has invalid format.", {"trust_data_type": self.kind}
)
) from err

def validate(self, keystore: KeyStore):
"""
Expand Down Expand Up @@ -103,11 +105,11 @@ def _validate_signature(self, keystore: KeyStore):

try:
verify_signature(pub_key, sig, msg)
except Exception:
except Exception as err:
raise ValidationError(
"failed to verify signature of trust data.",
{"key_id": key_id, "trust_data_type": self.signed.get("_type")},
)
) from err

def _validate_hash(self, keystore: KeyStore):
"""
Expand Down Expand Up @@ -199,8 +201,10 @@ def get_tags(self):
def get_digest(self, tag: str):
try:
return self.signed.get("targets", {})[tag]["hashes"]["sha256"]
except KeyError:
raise NotFoundException('could not find digest for tag "{}".'.format(tag))
except KeyError as err:
raise NotFoundException(
'could not find digest for tag "{}".'.format(tag)
) from err

def get_keys(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion requirements_dev.txt
@@ -1,4 +1,4 @@
-r requirements.txt
pytest-cov~=2.10.0
parsedatetime~=2.6
pylint~=2.5.3
pylint~=2.7.2