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

Fix getting repo security and analysis #884

Merged
merged 3 commits into from
Sep 27, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pontos/github/models/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,17 @@ class SecurityAndAnalysis(GitHubModel):

Attributes:
advanced_security: Status of GitHub Advanced Security is used
dependabot_security_updates: Status of Dependabot security updates are
used
secret_scanning: Status of Secret Scanning is used
secret_scanning_push_protection: Status of Secret Scanning Push
Protection is used
"""

advanced_security: SecurityAndAnalysisType
secret_scanning: SecurityAndAnalysisType
secret_scanning_push_protection: SecurityAndAnalysisType
advanced_security: Optional[SecurityAndAnalysisType] = None
dependabot_security_updates: Optional[SecurityAndAnalysisType] = None
secret_scanning: Optional[SecurityAndAnalysisType] = None
secret_scanning_push_protection: Optional[SecurityAndAnalysisType] = None


@dataclass
Expand Down
4 changes: 2 additions & 2 deletions pontos/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ def from_dict(cls, data: Dict[str, Any]):
value = cls._get_value(model_field_cls, value) # type: ignore # pylint: disable=line-too-long # noqa: E501
except TypeError as e:
raise ModelError(
f"Error while creating {cls.__name__}. Could not set value "
f"for '{name}' from '{value}'."
f"Error while creating {cls.__name__} model. Could not set "
f"value for property '{name}' from '{value}'."
) from e

if name in type_hints:
Expand Down
4 changes: 2 additions & 2 deletions tests/models/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class ExampleModel(Model):

with self.assertRaisesRegex(
ModelError,
"Error while creating ExampleModel. Could not set value for 'foo' "
"from '{'bar': 'baz'}'.",
"Error while creating ExampleModel model. Could not set value for "
"property 'foo' from '{'bar': 'baz'}'.",
):
ExampleModel.from_dict({"foo": {"bar": "baz"}})