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

Drop toml dependency #43

Merged
merged 1 commit into from
Sep 16, 2021
Merged

Drop toml dependency #43

merged 1 commit into from
Sep 16, 2021

Conversation

br3ndonland
Copy link
Owner

Description

While the TOML spec is alive and well, the toml package that was used in this project is dead (uiri/toml#267).

There are several alternatives:

  • rtoml is the fastest, but does not provide "round trip" guarantees (meaning that it can't load, then dump, and get an identical result). However, for simple loading and parsing it's fine. It also requires a Rust environment to compile from source, which may be a consideration on distributions like Alpine Linux.
  • tomli is another alternative, but it is read-only (writing requires a separate tomli-w package), and requires files to be opened in binary mode to parse TOML.
  • tomlkit is used by Poetry (and is written by the original author of Poetry), but is currently 70x slower than rtoml.

This PR will remove toml from the fastapi Poetry extras group, and make the necessary source code changes.

Rather than installing an alternative TOML package, the TOML logic will simply be removed from inboard, because the TOML parsing and settings loading was somewhat tangential to the focus of the project. A separate project, fastenv, is more focused on settings management, and may feature TOML support in the future.

Note that toml is still a sub-dependency of some dev-dependencies, including pre-commit and pytest.

Changes

Related

uiri/toml#267
uiri/toml#279 (comment)

https://toml.io/en/
uiri/toml#267
uiri/toml#279 (comment)

While the TOML spec is alive and well, the `toml` package that was used
in this project is dead (uiri/toml#267). There are several alternatives.
`rtoml` is the fastest, but does not provide "round trip" guarantees
(meaning that it can't load, then dump, and get an identical result).
However, for simple loading and parsing it's fine. `tomli` is another
alternative, but it is read-only (writing requires a separate `tomli-w`
package), and requires files to be opened in binary mode to parse TOML.
`tomlkit` is used by Poetry (from the Poetry author), but is currently
70x slower than `rtoml`.

It's also important to note that the TOML parsing and settings loading
is somewhat tangential to the focus of the inboard project. A separate
project, https://github.com/br3ndonland/fastenv, is more focused on
settings management, and may feature TOML support in the future.

This commit will remove `toml` from the `fastapi` Poetry extras group.
Note that `toml` is still a sub-dependency of some `dev-dependencies`,
including pre-commit and pytest.
@vercel
Copy link

vercel bot commented Sep 16, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/br3ndonland/inboard/4HT7LqmVEhJDeMqBoPF6y73VYd8c
✅ Preview: https://inboard-git-drop-toml-br3ndonland.vercel.app

@codecov
Copy link

codecov bot commented Sep 16, 2021

Codecov Report

Merging #43 (619f63c) into develop (ddffe97) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##           develop       #43   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines          286       264   -22     
=========================================
- Hits           286       264   -22     
Flag Coverage Δ
unit 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
inboard/app/main_fastapi.py 100.00% <100.00%> (ø)
inboard/app/utilities_fastapi.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ddffe97...619f63c. Read the comment docs.

@br3ndonland br3ndonland merged commit d7eb82a into develop Sep 16, 2021
@br3ndonland br3ndonland deleted the drop-toml branch September 16, 2021 00:30
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Sep 16, 2021

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.74%.

Quality metrics Before After Change
Complexity 0.50 ⭐ 0.48 ⭐ -0.02 👍
Method Length 31.60 ⭐ 31.37 ⭐ -0.23 👍
Working memory 5.47 ⭐ 5.20 ⭐ -0.27 👍
Quality 88.78% 89.52% 0.74% 👍
Other metrics Before After Change
Lines 266 234 -32
Changed files Quality Before Quality After Quality Change
inboard/app/main_fastapi.py 78.15% ⭐ 80.29% ⭐ 2.14% 👍
inboard/app/utilities_fastapi.py 82.36% ⭐ 83.20% ⭐ 0.84% 👍
tests/conftest.py 92.91% ⭐ 92.73% ⭐ -0.18% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
tests/conftest.py uvicorn_options_custom 0 ⭐ 34 ⭐ 10 😞 79.09% ⭐ Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant