mm21 / trilium-alchemy

Python SDK and CLI toolkit for Trilium Notes
GNU Affero General Public License v3.0
10 stars 1 forks source link

pydanic missing from pyproject.toml #8

Closed jwhonce closed 1 year ago

jwhonce commented 1 year ago

pydanic included in poetry.lock but not listed in pyproject.toml

mm21 commented 1 year ago

Hi, thanks for submitting this. In general, not everything in poetry.lock needs to be in pyproject.toml - the former has the full tree of dependencies (including those from other dependencies) while the latter has only the direct dependencies for the project. In this case pydantic is used by the dependency trilium-client, which is an auto-generated HTTP client for accessing ETAPI.

That said, since the generated pydantic models are used directly in this project and pydantic is imported (mostly for typing), it should probably be considered a direct dependency as well.

Just wondering though, are you using a tool to format pyproject.toml? The ideal way to maintain dependencies is to use Poetry commands rather than updating pyproject.toml manually. For example to make this change I would have run:

poetry add pydantic@^1.10.12

This will update the content-hash under [metadata] in poetry.lock as well, which as I understand is a hash of the relevant content in pyproject.toml.

Can you please try that and include the change in poetry.lock? And while I appreciate the effort in the other changes like alphabetizing and aligning, I'm not sure if they're necessary. It may be a pain to re-align all the other lines when adding a longer config item for example.

jwhonce commented 1 year ago

I am using a toml plugin for vs-code and letting it loose. I have not used poetry before, so I will your suggestion now.

I was reading the code and saw the pydantic import and didn't remember seeing it in pyproject.toml which starting me down this path.

jwhonce commented 1 year ago

I see where category was removed from the lock file, but could not find any option to restore it. Maybe it is the difference between poetry versions?

mm21 commented 1 year ago

Yeah, it looks like the lockfile categories were deprecated so this is expected. I upgraded my poetry version to be consistent.

mm21 commented 1 year ago

You inspired me to look into a toml formatter for this project, and I found toml-sort which works pretty well. It doesn't support aligning the assignments like vs-code though. I don't use vs-code myself (I prefer more minimal text editors for most work).

Now you can run black and toml-sort by running:

scons format

I'm planning to add a hook to run it automatically upon commit.