-
Notifications
You must be signed in to change notification settings - Fork 132
Make pylance recognize wildcard imports #133
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bbe09d2
adding exports directly to top level __all__
barnjamin 7aa6597
apply black formatter
barnjamin 9b8ead9
adding initial generate script
barnjamin 1aae421
fmt
barnjamin 0428128
rm all from all
barnjamin aebf594
adding check to travis
barnjamin 0c35e44
reading in original __init__ and using its imports, dont write to fil…
barnjamin f2b23e5
make messages more profesh
barnjamin 3d6af86
fix flags after black formatted them
barnjamin b141814
y
barnjamin 66ffc08
flippin black formatter
barnjamin 0e7be66
help text fix
barnjamin b75d3d2
asdfasdf
barnjamin 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 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 |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| ## File generated from scripts/generate_init.py. | ||
| ## DO NOT EDIT DIRECTLY | ||
|
|
||
| from .ast import * | ||
| from .ast import __all__ as ast_all | ||
| from .ir import * | ||
| from .ir import __all__ as ir_all | ||
| from .compiler import ( | ||
| MAX_TEAL_VERSION, | ||
| MIN_TEAL_VERSION, | ||
| DEFAULT_TEAL_VERSION, | ||
| CompileOptions, | ||
| compileTeal, | ||
| ) | ||
| from .types import TealType | ||
| from .errors import TealInternalError, TealTypeError, TealInputError, TealCompileError | ||
| from .config import MAX_GROUP_SIZE, NUM_SLOTS | ||
|
|
||
| __all__ = [ | ||
| "Expr", | ||
| "LeafExpr", | ||
| "Addr", | ||
| "Bytes", | ||
| "Int", | ||
| "EnumInt", | ||
| "Arg", | ||
| "TxnType", | ||
| "TxnField", | ||
| "TxnExpr", | ||
| "TxnaExpr", | ||
| "TxnArray", | ||
| "TxnObject", | ||
| "Txn", | ||
| "GtxnExpr", | ||
| "GtxnaExpr", | ||
| "TxnGroup", | ||
| "Gtxn", | ||
| "GeneratedID", | ||
| "ImportScratchValue", | ||
| "Global", | ||
| "GlobalField", | ||
| "App", | ||
| "AppField", | ||
| "OnComplete", | ||
| "AppParam", | ||
| "AssetHolding", | ||
| "AssetParam", | ||
| "InnerTxnBuilder", | ||
| "InnerTxn", | ||
| "Array", | ||
| "Tmpl", | ||
| "Nonce", | ||
| "UnaryExpr", | ||
| "Btoi", | ||
| "Itob", | ||
| "Len", | ||
| "BitLen", | ||
| "Sha256", | ||
| "Sha512_256", | ||
| "Keccak256", | ||
| "Not", | ||
| "BitwiseNot", | ||
| "Sqrt", | ||
| "Pop", | ||
| "Balance", | ||
| "MinBalance", | ||
| "BinaryExpr", | ||
| "Add", | ||
| "Minus", | ||
| "Mul", | ||
| "Div", | ||
| "Mod", | ||
| "Exp", | ||
| "BitwiseAnd", | ||
| "BitwiseOr", | ||
| "BitwiseXor", | ||
| "ShiftLeft", | ||
| "ShiftRight", | ||
| "Eq", | ||
| "Neq", | ||
| "Lt", | ||
| "Le", | ||
| "Gt", | ||
| "Ge", | ||
| "GetBit", | ||
| "GetByte", | ||
| "Ed25519Verify", | ||
| "Substring", | ||
| "Extract", | ||
| "Suffix", | ||
| "SetBit", | ||
| "SetByte", | ||
| "NaryExpr", | ||
| "And", | ||
| "Or", | ||
| "Concat", | ||
| "WideRatio", | ||
| "If", | ||
| "Cond", | ||
| "Seq", | ||
| "Assert", | ||
| "Err", | ||
| "Return", | ||
| "Approve", | ||
| "Reject", | ||
| "Subroutine", | ||
| "SubroutineDefinition", | ||
| "SubroutineDeclaration", | ||
| "SubroutineCall", | ||
| "ScratchSlot", | ||
| "ScratchLoad", | ||
| "ScratchStore", | ||
| "ScratchStackStore", | ||
| "ScratchVar", | ||
| "MaybeValue", | ||
| "BytesAdd", | ||
| "BytesMinus", | ||
| "BytesDiv", | ||
| "BytesMul", | ||
| "BytesMod", | ||
| "BytesAnd", | ||
| "BytesOr", | ||
| "BytesXor", | ||
| "BytesEq", | ||
| "BytesNeq", | ||
| "BytesLt", | ||
| "BytesLe", | ||
| "BytesGt", | ||
| "BytesGe", | ||
| "BytesNot", | ||
| "BytesZero", | ||
| "ExtractUint16", | ||
| "ExtractUint32", | ||
| "ExtractUint64", | ||
| "Log", | ||
| "While", | ||
| "For", | ||
| "Break", | ||
| "Continue", | ||
| "Op", | ||
| "Mode", | ||
| "TealComponent", | ||
| "TealOp", | ||
| "TealLabel", | ||
| "TealBlock", | ||
| "TealSimpleBlock", | ||
| "TealConditionalBlock", | ||
| "LabelReference", | ||
| "MAX_TEAL_VERSION", | ||
| "MIN_TEAL_VERSION", | ||
| "DEFAULT_TEAL_VERSION", | ||
| "CompileOptions", | ||
| "compileTeal", | ||
| "TealType", | ||
| "TealInternalError", | ||
| "TealTypeError", | ||
| "TealInputError", | ||
| "TealCompileError", | ||
| "MAX_GROUP_SIZE", | ||
| "NUM_SLOTS", | ||
| ] |
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 |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import argparse, os, sys | ||
| from pyteal import __all__ as static_all | ||
|
|
||
|
|
||
| # Start of the template to be appended to | ||
| pyi_template = """## File generated from scripts/generate_init.py. | ||
| ## DO NOT EDIT DIRECTLY | ||
|
|
||
| """ | ||
|
|
||
| # Template for __all__ export list | ||
| all_template = """__all__ = [ | ||
| {}, | ||
| ]""" | ||
|
|
||
| # Flags to denote the beginning/end of the __all__ exports in __init__.py | ||
| begin_flag = "# begin __all__" | ||
| end_flag = "# end __all__" | ||
|
|
||
| # Make it safe to run from anywhere | ||
| curr_dir = os.path.dirname(os.path.abspath(__file__)) | ||
| orig_dir = os.path.join(curr_dir, os.path.join("..", "pyteal")) | ||
|
|
||
| # Path to pyi | ||
| pyi_file = "__init__.pyi" | ||
| orig_file = os.path.join(orig_dir, pyi_file) | ||
|
|
||
| # Path to py | ||
| py_file = "__init__.py" | ||
| init_file = os.path.join(orig_dir, py_file) | ||
|
|
||
|
|
||
| def generate_tmp(): | ||
| with open(init_file, "r") as f: | ||
| init_contents = f.read() | ||
|
|
||
| start_idx = init_contents.index(begin_flag) | ||
| end_idx = init_contents.index(end_flag) | ||
|
|
||
| all_imports = ",\n ".join(['"{}"'.format(s) for s in static_all]) | ||
|
|
||
| return ( | ||
| pyi_template | ||
| + init_contents[:start_idx] | ||
| + all_template.format(all_imports) | ||
| + init_contents[end_idx + len(end_flag) :] | ||
| ) | ||
|
|
||
|
|
||
| def is_different(regen): | ||
| if not os.path.exists(orig_file): | ||
| return True | ||
|
|
||
| with open(orig_file, "r") as f: | ||
| orig_lines = f.readlines() | ||
|
|
||
| curr_lines = regen.split("\n") | ||
|
|
||
| return orig_lines == curr_lines | ||
|
|
||
|
|
||
| def overwrite(regen): | ||
| with open(orig_file, "w") as f: | ||
| f.write(regen) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument( | ||
| "--check", | ||
| action="store_true", | ||
| help="Only check if the generated file would change", | ||
| ) | ||
| args = parser.parse_args() | ||
|
|
||
| regen = generate_tmp() | ||
|
|
||
| if args.check: | ||
| if is_different(regen): | ||
| print( | ||
| "The __init__.pyi needs to be regenerated. Please run scripts/generate_init.py" | ||
| ) | ||
| sys.exit(1) | ||
| print("No changes in __init__.py") | ||
| sys.exit(0) | ||
|
|
||
| overwrite(regen) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.