-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
64 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from typing import Optional, Callable | ||
from mypy.nodes import Var, SymbolTableNode, MDEF | ||
from mypy.plugin import Plugin, AnalyzeTypeContext | ||
|
||
|
||
class TxReceiptAttributePlugin(Plugin): | ||
|
||
def get_type_analyze_hook(self, fullname: str) -> Optional[Callable]: | ||
def func(ctx: AnalyzeTypeContext) -> None: | ||
symbol_table = ctx.api.lookup_fully_qualified('web3.types.TxReceipt') | ||
names = symbol_table.node.names | ||
type_items = symbol_table.node.typeddict_type.items | ||
for attr_name, attr_type in type_items.items(): | ||
if getattr(attr_type, "items", None): | ||
node = Var(attr_name, attr_type) | ||
node.info = attr_type.items[0].type | ||
else: | ||
node = Var(attr_name, attr_type) | ||
node.info = attr_type.type | ||
names[node.name] = SymbolTableNode(MDEF, node) | ||
breakpoint() | ||
return symbol_table.node.typeddict_type | ||
|
||
if 'TxReceipt' in fullname: | ||
return func | ||
return None | ||
|
||
|
||
def plugin(version: str) -> Plugin: | ||
return TxReceiptAttributePlugin |
This file contains 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from typing import TYPE_CHECKING | ||
|
||
from astroid import MANAGER, Call | ||
|
||
if TYPE_CHECKING: | ||
from pylint.lint import PyLinter | ||
|
||
print("plugin loaded") | ||
|
||
def register(linter: "PyLinter") -> None: | ||
"""This required method auto registers the checker during initialization. | ||
:param linter: The linter to register the checker to. | ||
""" | ||
print('register') | ||
|
||
def transform(node): | ||
print('transform ran') | ||
|
||
MANAGER.register_transform(Call, transform) |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
def func(): | ||
pass | ||
|
||
func() |