Skip to content
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

fix: Use 'tomli' package instead of 'toml' package. #70

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

emcd
Copy link
Contributor

@emcd emcd commented Jul 7, 2024

The 'toml' package breaks on valid 'pyproject.toml' files which prevents Tryceratops from being integrated properly.

The 'tomli' package provides TOML 1.0 and 'tomllib' compatibility.
Had a similar patch accepted by the YAPF project in 2022.

Example of breakage with toml:

$ hatch --env develop run tryceratops
Traceback (most recent call last):
  File "/home/me/.local/share/hatch/env/virtual/accretive/5On6b-gH/develop/bin/tryceratops", line 8, in <module>
    sys.exit(main())
  File "/home/me/.local/share/hatch/env/virtual/accretive/5On6b-gH/develop/lib/python3.8/site-packages/tryceratops/__main__.py", line 66, in main
    entrypoint(prog_name="tryceratops")
  File "/home/me/.local/share/hatch/env/virtual/accretive/5On6b-gH/develop/lib/python3.8/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/me/.local/share/hatch/env/virtual/accretive/5On6b-gH/develop/lib/python3.8/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/me/.local/share/hatch/env/virtual/accretive/5On6b-gH/develop/lib/python3.8/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/me/.local/share/hatch/env/virtual/accretive/5On6b-gH/develop/lib/python3.8/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/me/.local/share/hatch/env/virtual/accretive/5On6b-gH/develop/lib/python3.8/site-packages/tryceratops/__main__.py", line 48, in entrypoint
    pyproj_config = load_config(dir)
  File "/home/me/.local/share/hatch/env/virtual/accretive/5On6b-gH/develop/lib/python3.8/site-packages/tryceratops/files/discovery.py", line 118, in load_config
    config = toml.load(toml_file)
  File "/home/me/.local/share/hatch/env/virtual/accretive/5On6b-gH/develop/lib/python3.8/site-packages/toml/decoder.py", line 134, in load
    return loads(ffile.read(), _dict, decoder)
  File "/home/me/.local/share/hatch/env/virtual/accretive/5On6b-gH/develop/lib/python3.8/site-packages/toml/decoder.py", line 362, in loads
    raise TomlDecodeError("Unterminated string found."
toml.decoder.TomlDecodeError: Unterminated string found. Reached end of file. (line 292 column 1 char 8542)

Successful run after switch to tomllib:

$ hatch --env develop run tryceratops
Done processing!
Nothing to check!
$ hatch --env develop run tryceratops sources
Done processing!
Processed 36 files
Everything clean!
$ hatch --env develop run pip freeze | grep tryceratops
tryceratops @ git+https://github.com/emcd/tryceratops@e1c57b6a1ea54b5b6e24b39bdfddb6b9d1ff51a4

@guilatrova
Copy link
Owner

@emcd Your PR looks good and feels ready to be merged. I just need to update/fix the GHA to ensure all tests are still passing (which I believe will be).

I'm planning on doing it later today, so expect a release today.

The 'toml' package breaks on valid 'pyproject.toml' files which prevents
Tryceratops from being integrated properly.

The 'toml' package provides TOML 1.0 and 'tomllib' compatibility.
@guilatrova guilatrova merged commit d20c153 into guilatrova:main Jul 8, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants