I'll continue with the posts and content on LinkedIn. There just in't enough characters to do it all here... Follow me on buff.ly/v7MR0oS
I'll continue with the posts and content on LinkedIn. There just in't enough characters to do it all here... Follow me on buff.ly/v7MR0oS
A print on 'user' and 'user.name' shows:
"id=1 name='John Doe' email='some@email.com'"
and
"John Doe"
As a first in the pydantic series, let's start with the basics. The goal of the whole series is to be able to validate the model as well as being able to generate the same json as the input, to verify we didn't miss anything.
Did you ever ran into a tricky json, with a lot of dicts, where the dict in the dicts were inconsistent with variables key names?
You mean just the instruction to load the json in the model. True. But defining the whole model takes a few more lines ๐
Especially if the json is tricky...
I've working on parsing a json structure into a pydantic model. I'm planning to write a couple of posts on this. Is this something you've been playing with?
Anything specific you ran into?
Perhaps I could write about something specific if you have certain interests. Please let me know.
Sounds solid. I'd prefer task over just. I had written a comparison here github.com/bartdorlandt...
Dealing with #Ansible & #docker compose on #synology systems and an alternative #taskfile option
Let's dive in: buff.ly/xoSjQ1A
The alternative with taskfile: buff.ly/bMcd7SG
Using #Taskfile to deal with docker-compose vs docker compose on different systems
buff.ly/bMcd7SG
#pyrefly found at pyrefly.org is a new one written in rust and is created by #meta open source.
#ty found at buff.ly/rJg94P5 is created by astral-sh (creators of #ruff and #uv) and is also written in rust. Note: this isn't ready for production yet.
Have you tried any of the new kids on the block?
Most of us already got used to annotate our #python code with typehints. If I had to guess, I would say that most people are using #mypy for checking the types.
Did you know that other checkers have emerged these days?
I hope this project will help you in your migrations and make them smooth and quick.
In case you run into challenges, don't hesitate to reach out.
The `-n` flag will do a dry run and creates a new file instead of moving the old one out of the way, allowing you to verify its contents.
To do the actual migration, just `uvx convert-poetry2uv pyproject.toml`. (Your original file will be backed up)
I looked for existing ones, but didn't find any that met my requirements or desires. So, nothing to do than creating my own. And so it was born. buff.ly/zmp2ptg
to make it really easy to use, when you already have uv installed is just calling it directly: `uvx convert-poetry2uv -n pyproject.toml`
Doing it by hand is just plain annoying and it will be easy to sneak in some errors.
After I did that once, and imaging other would be in the same pickle. I thought it would be useful to have a migration script to convert the existing #poetry `pyproject.toml` to one that can be consumed by #uv.
`uv add --dev $library` to make it part of the development group.
Even loading libraries from your requirements file is easy, `uv add -r requirements.txt`.
Now, you might want to migrate other repositories to have some consistency. How to migrate your existing repo's to uv.
Creating a uv repo is easy, just run `uv init $project` and you are off to the races. Using it for new projects is easy if you are already used to poetry. The commands are quite similar. Just add a few libraries with `uv add $library` or
When I encountered #uv I fell for it right away. I was already using ruff for a while and started looking into rye, which was the intermediate step before it became uv.
With this in place, the uv run is part of the script and calling it directly from the CLI is now possible.
Have a read on my complete article
buff.ly/KQ8kqVN
This provides the dependency of still writing `uv run` for the command, and it doesn't allow you to have that script as part of your PATH and just be able to call it.
So, let's improve that by changing the shebang.
`#!/usr/bin/env -S uv run --script`
Previously I share a post on how you can use `uv run -s script.py` to run that script and have `uv` handle the dependencies. The original script is showing the shebang is pointing to a python3 executable.
When we combine that with uv, buff.ly/cWc4fBv we can easily run the script without having to activate a virtualenv or specify the python interpreter. And it will just take care of it. Assume the script has the name `script.py` we would call it with `uv run -s script.py`.
Are you already using this?
Ever wanted to run a python script, without having to specify a virtualenv?
Given buff.ly/cVEXJle we can build scripts as we would normally, though now add a few comments to it to specify the dependencies.
Yeah indeed. I always had that setting enabled for poetry. It was the default for me.
Shell can be done by a plugin indeed. Though it is nothing more than enabling the venv. I just have an alias called `venv`:
`source ./.venv/bin/activate` and vscode picks it up automatically
Still want to migrate, use a conversion tool, like pypi.org/project/conv...
Consider this done.
Find more details on the role on github:
https://buff.ly/3BVaf4R
Are you using poetry, or have you switched to uv? Or perhaps using something else?
Poetry had a new release recently, version 2.0. Given the number, this means stuff broke ;) E.g. the poetry shell command is no more. The pyproject.toml is updated and now supporting the project header. (PEP 621)
This also meant I had to update my ansible role for poetry (bartdorlandt.poetry).
I've written an article on linkedIn on my tool to migration from poetry to uv. Having uv is awesome, though the migration of each repo isn't...
This tool will make your life a bit easier. Have fun ๐
https://buff.ly/3BPX5WI
PS. For those who are using #shortcat (https://shortcat.app/), this unfortunately doesn't work to active the toggle.
I found it to be very powerful for several other things as well and I've replaced spotlight with it.
No more annoyances for me, at least not regarding the notch ๐ซ
I hope it'll work for you as well. Or have you find another solution?