-
Notifications
You must be signed in to change notification settings - Fork 7
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
Write Compiler
class
#2
Conversation
5646916
to
44d7de8
Compare
@pipermerriam pinging for initial review - CI won't pass until |
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.
Generally 👍
In a subsequent PR, it might be good to start establishing the basic documentation for the API as well so that the way it is intended to be used can begin being defined.
tox.ini
Outdated
@@ -39,4 +40,5 @@ basepython=python | |||
extras=lint | |||
commands= | |||
flake8 {toxinidir}/twig {toxinidir}/tests | |||
isort --recursive --check-only --diff {toxinidir}/twig {toxinidir}/tests | |||
black --check --diff {toxinidir}/twig/ --check --diff {toxinidir}/tests/ |
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.
tabs
def generate_inline_sources(compiler_output: Dict[str, Any]): | ||
for path in compiler_output.keys(): | ||
contract_type = path.split("/")[-1].split(".")[0] | ||
yield b.inline_source(contract_type, compiler_output) |
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.
neat that the builder tool can be used here.
twig/utils/filesystem.py
Outdated
SOURCES_GLOB = "**/*.vy" | ||
|
||
|
||
def collect_sources(path, glob=SOURCES_GLOB): |
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.
In theory, this function would be a public API which would imply it should live outside of utils
(which should be _utils
under our new paradigm)
def __init__(self, sources, backend): | ||
self.sources = sources | ||
self.backend = backend | ||
self.output = self.backend.compile(self.sources) |
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.
I think this should be a computed property rather than populating it eagerly during initialization. No strong reason other than compilation often being expensive.
a7df574
to
71b9ed2
Compare
What was wrong?
#1
How was it fixed?
For the most part, I followed what was outlined in #1, but added
output
(i.e. the compiler_output) as an attribute toCompiler
, since it falls more in line with howpy-ethpm
'sbuilder
functions are currently designed.An alternative would be to adjust the
builder
functions inpy-ethpm
to support something likeBut I thought this would be a better way to get this working initially
Cute Animal Picture