glideapps / glideapps/quicktype

Please do not use assert() in python to enforce interface constraints.

Open
#1,911 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
13.9k
Forks
1.2k
Avg merge
8h 53m
Merged PRs (30d)
369

Description

A typical generated python class looks like this:
```
@dataclass
class UpdateIssueEventNoteSchema:
note: str

@staticmethod
def from_dict(obj: Any) -> 'UpdateIssueEventNoteSchema':
assert isinstance(obj, dict)
note = from_str(obj.get("note"))
return UpdateIssueEventNoteSchema(note)
```
However, the assert and the enclosed code might will be removed when compiling to optimised byte code.

Please see https://bandit.readthedocs.io/en/latest/plugins/b101_assert_used.html for more information.

I would suggest to throw an `AssertionError` explicitly.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.