Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Keys must be str, int, float, bool or None, not PosixPath #3900

Closed
anudit opened this issue Apr 1, 2024 · 1 comment · Fixed by #3901
Closed

Keys must be str, int, float, bool or None, not PosixPath #3900

anudit opened this issue Apr 1, 2024 · 1 comment · Fixed by #3901
Labels
bug - type 0 compiler halts or panics instead of generating code priority - HIGH

Comments

@anudit
Copy link

anudit commented Apr 1, 2024

Version Information

  • Vyper Version: 0.4.0b5+commit.a9ee641
  • OS: osx
  • Python Version: Python 3.11.6

What's your issue about?

vyper -f combined_json contract.vy errors out with
TypeError: keys must be str, int, float, bool or None, not PosixPath

vyper -f abi contract.vy other formatters seem to work though.

Verbose logs

cli specified: `Settings(compiler_version=None, optimize=None, evm_version=None, experimental_codegen=None)`
Traceback (most recent call last):
  File "/opt/homebrew/bin/vyper", line 8, in <module>
    sys.exit(_parse_cli_args())
             ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/vyper/cli/vyper_compile.py", line 63, in _parse_cli_args
    return _parse_args(sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/vyper/cli/vyper_compile.py", line 211, in _parse_args
    _cli_helper(f, output_formats, compiled)
  File "/opt/homebrew/lib/python3.11/site-packages/vyper/cli/vyper_compile.py", line 68, in _cli_helper
    print(json.dumps(compiled), file=f)
          ^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
           ^^^^^^^^^^^^^^^^^
TypeError: keys must be str, int, float, bool or None, not PosixPath

Looks like it errors out on the json.dumps here

print(json.dumps(compiled), file=f)

@anudit
Copy link
Author

anudit commented Apr 1, 2024

Changing

ret[file_path] = output

to

ret[str(file_path)] = output

fixed it as PosixPaths as keys could not be serialized by json.dumps

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug - type 0 compiler halts or panics instead of generating code priority - HIGH
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants