Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Compile error, TypeError: data must be str, not Content [APE-1593] #136

Open
gcc2ge opened this issue Dec 7, 2023 · 0 comments
Open

Compile error, TypeError: data must be str, not Content [APE-1593] #136

gcc2ge opened this issue Dec 7, 2023 · 0 comments

Comments

@gcc2ge
Copy link

gcc2ge commented Dec 7, 2023

Environment information

  • ape and plugin versions:
$ ape --version
# 0.6.26

$ ape plugins list
# Installed Plugins
  cairo       0.6.1
  starknet    0.6.0
  • Python Version: 3.9.12
  • OS: macOS

What went wrong?

Please include information like:

  • what command you ran
    ape compile

  • the code that caused the failure (see this link for help with formatting code)

if source.content:
    destination_path.parent.mkdir(parents=True, exist_ok=True)
    destination_path.touch()
    destination_path.write_text(source.content)
  • full output of the error you received
Traceback (most recent call last):
  File "/Users/usesr/Downloads/shefcraft/venv/bin/ape", line 8, in <module>
    sys.exit(cli())
  File "/Users/usesr/Downloads/shefcraft/venv/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/Users/usesr/Downloads/shefcraft/venv/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/Users/usesr/Downloads/shefcraft/venv/lib/python3.9/site-packages/ape/_cli.py", line 37, in invoke
    return super().invoke(ctx)
  File "/Users/usesr/Downloads/shefcraft/venv/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/usesr/Downloads/shefcraft/venv/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/usesr/Downloads/shefcraft/venv/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/Users/usesr/Downloads/shefcraft/venv/lib/python3.9/site-packages/click/decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/Users/usesr/Downloads/shefcraft/venv/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/Users/usesr/Downloads/shefcraft/venv/lib/python3.9/site-packages/ape_compile/_cli.py", line 83, in cli
    contract_types = cli_ctx.project_manager.load_contracts(
  File "/Users/usesr/Downloads/shefcraft/venv/lib/python3.9/site-packages/ape/managers/project/manager.py", line 668, in load_contracts
    manifest = self.local_project.create_manifest(
  File "/Users/usesr/Downloads/shefcraft/venv/lib/python3.9/site-packages/ape/managers/project/types.py", line 179, in create_manifest
    compiled_contract_types = self._compile(project_sources)
  File "/Users/usesr/Downloads/shefcraft/venv/lib/python3.9/site-packages/ape/managers/project/types.py", line 211, in _compile
    return self.compiler_manager.compile(project_sources.sources_needing_compilation)
  File "/Users/usesr/Downloads/shefcraft/venv/lib/python3.9/site-packages/ape/managers/compilers.py", line 148, in compile
    compiled_contracts = compiler.compile(paths_to_compile, base_path=contracts_folder)
  File "/Users/usesr/Downloads/shefcraft/venv/lib/python3.9/site-packages/ape_cairo/compiler.py", line 240, in compile
    self.load_dependencies()
  File "/Users/usesr/Downloads/shefcraft/venv/lib/python3.9/site-packages/ape_cairo/compiler.py", line 226, in load_dependencies
    destination_path.write_text(source.content)
  File "/Users/usesr/opt/anaconda3/lib/python3.9/pathlib.py", line 1283, in write_text
    raise TypeError('data must be str, not %s' %
TypeError: data must be str, not Content

How can it be fixed?

file: ape_cairo/compiler.py", line 226, in load_dependencies

if source.content:
    destination_path.parent.mkdir(parents=True, exist_ok=True)
    destination_path.touch()
    destination_path.write_text(str(source.content)) # change source.content to str(source.content)

Fill this in if you have ideas on how the bug could be fixed.

@vany365 vany365 changed the title Compile error, TypeError: data must be str, not Content Compile error, TypeError: data must be str, not Content [APE-1593] Dec 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant