Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tom Niget
typon
Commits
30e86670
Commit
30e86670
authored
Aug 10, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helper class for displaying synthesized annotations in unparsed code
parent
fab94334
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
trans/transpiler/phases/typing/block.py
trans/transpiler/phases/typing/block.py
+2
-2
trans/transpiler/phases/utils.py
trans/transpiler/phases/utils.py
+12
-1
No files found.
trans/transpiler/phases/typing/block.py
View file @
30e86670
...
...
@@ -11,7 +11,7 @@ from transpiler.phases.typing.class_ import ScoperClassVisitor
from
transpiler.phases.typing.scope
import
VarDecl
,
VarKind
,
ScopeKind
,
Scope
from
transpiler.phases.typing.types
import
BaseType
,
TypeVariable
,
FunctionType
,
\
Promise
,
TY_NONE
,
PromiseKind
,
TupleType
,
UserType
,
TypeType
,
ModuleType
from
transpiler.phases.utils
import
PlainBlock
from
transpiler.phases.utils
import
PlainBlock
,
AnnotationName
@
dataclass
...
...
@@ -141,7 +141,7 @@ class ScoperBlockVisitor(ScoperVisitor):
def
annotate_arg
(
self
,
arg
:
ast
.
arg
)
->
BaseType
:
if
arg
.
annotation
is
None
:
res
=
TypeVariable
()
arg
.
annotation
=
ast
.
Name
(
id
=
str
(
res
),
ctx
=
ast
.
Load
()
)
arg
.
annotation
=
AnnotationName
(
res
)
return
res
else
:
return
self
.
visit_annotation
(
arg
.
annotation
)
...
...
trans/transpiler/phases/utils.py
View file @
30e86670
...
...
@@ -31,3 +31,14 @@ class NodeVisitorSeq:
@
dataclass
class
PlainBlock
(
ast
.
stmt
):
body
:
list
[
ast
.
stmt
]
@
dataclass
class
AnnotationName
:
inner
:
"transpiler.phases.typing.types.BaseType"
@
property
def
id
(
self
):
return
str
(
self
.
inner
)
AnnotationName
.
__name__
=
"Name"
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment