-
Notifications
You must be signed in to change notification settings - Fork 56
Add type annotations #519
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
Open
CoolCat467
wants to merge
20
commits into
ethteck:main
Choose a base branch
from
CoolCat467:add-type-annotations
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add type annotations #519
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b3d80ae
WIP add type annotations
CoolCat467 0df25a4
Add ruff linting rules
CoolCat467 b0aade7
Revert import changes
CoolCat467 826594c
Run typing-related ruff linting
CoolCat467 1f41416
Don't use `typing.override`
CoolCat467 565a48d
Workaround for `typing.NotRequired` for older python
CoolCat467 62e5232
Add more missing annotations
CoolCat467 e4583f9
Support older python without TypeAlias
CoolCat467 a1a9eb6
Revert "Run typing-related ruff linting"
CoolCat467 20f8c72
Fix syntax error
CoolCat467 ff18411
Disable strict mode for now
CoolCat467 bb1a107
Fix a ton of mypy issues
CoolCat467 dcc29d4
Fix runtime issue
CoolCat467 bb1304c
Apply ruff formatting
CoolCat467 3e340be
Ruff autofixes
CoolCat467 801581c
Ruff unsafe autofixes
CoolCat467 00781df
Fix/ignore remaining mypy issues
CoolCat467 e475e74
Fix 3.9 support
CoolCat467 17780cb
Merge branch 'main' into add-type-annotations
CoolCat467 60b8238
Run ruff formatting
CoolCat467 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,19 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from abc import ABC, abstractmethod | ||
| from typing import Set | ||
|
|
||
|
|
||
| class Disassembler(ABC): | ||
| __slots__ = () | ||
|
|
||
| @abstractmethod | ||
| def configure(self): | ||
| def configure(self) -> None: | ||
| raise NotImplementedError("configure") | ||
|
|
||
| @abstractmethod | ||
| def check_version(self, skip_version_check: bool, splat_version: str): | ||
| raise NotImplementedError("check_version") | ||
|
|
||
| @abstractmethod | ||
| def known_types(self) -> Set[str]: | ||
| def known_types(self) -> set[str]: | ||
| raise NotImplementedError("known_types") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,16 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from . import disassembler | ||
| from typing import Set | ||
|
|
||
|
|
||
| class NullDisassembler(disassembler.Disassembler): | ||
| def configure(self): | ||
| __slots__ = () | ||
|
|
||
| def configure(self) -> None: | ||
| pass | ||
|
|
||
| def check_version(self, skip_version_check: bool, splat_version: str): | ||
| pass | ||
|
|
||
| def known_types(self) -> Set[str]: | ||
| def known_types(self) -> set[str]: | ||
| return set() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the PR makes use of this union syntax a lot but this was actually introduced in python 3.10 (source), unlike splat which (according to angheloalf) supports 3.9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, this is not a problem because of using
from __future__ import annotations. Anything that's trying to use annotations at runtime uses something liketyping.get_type_hints, which deals with string versions of annotations properly.