my python project setup (+ all tools) (intermediate) anthony explains
HTML-код
- Опубликовано: 4 окт 2024
- today I go over all the tools I use to set up my projects, as well as the differences between 1-file libraries, multi-file libraries, and applications!
python packaging src layout (which I don't use): • python packaging: src ...
declarative metadata / setup.cfg: • python packaging: basi...
playlist: • anthony explains
==========
twitch: / anthonywritescode
dicsord: / discord
twitter: / codewithanthony
github: github.com/aso...
stream github: github.com/ant...
I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below! - Наука
Anthony is a living python legend.
Wrote his own "black"
Works on pytest, precommit.
Still humble to teach us his ways. ♥️
Meanwhile my helloworld project never took off 😂
Preach, friend! What a library of knowledge this one developer is!
"Hey, I wrote eveything except for the language itself, use my stuff, it's free..." legend.
Man, I just feel like will I ever be even half the developer you are. You have such a vast knowledge base in python, CI, git and everything.
Damn, you developed all those amazing libraries? I can't thank you enough for pre-commit, so useful.
This video was extremely educational and full of very valuable information, thank you!
I stumbled on your channel a few weeks ago and you have amazing content. I really appreciate you sharing your setup!
Great video! I've looked at your config files before, and it all now makes more sense ;-]
I'm still a beginner so some parts flew over my head but this is inspiring stuff. A goal to work towards and use as a reference.
Lovely! Pretty helpful content. Learns a lot.
You are great! Always high value content
a big +1 to single quotes. black's reasoning around double quotes is some of the dumbest I've read
I understood that you want to know when a dependency of your library becomes incompatible, but how do you track the last working (dependency) versions before said breakage?
Also how does it affect your users at install time if the dependencies are not pinned?
Sorry if I might have misunderstood this part.
Thanks for the great video!
there's no need to track it, you can simply bisect the versions when a breakage occurs (and for the ~60ish libraries I maintain this has really only happened a handful of times in the last decade so it's not really worth any extra hassle). it doesn't really affect users if you don't pin, only if you do (where users will be often unable to install due to pip's conflict resolution)
Would you do a video about best practices migrating from old code to new? Example python 2 to 3 :D library dependencies?
I have a whole playlist about 2-to-3, though it's kind of old: ruclips.net/p/PLWBKAf81pmOZOukFi2KyQJ7QMNDzcq2yT
You wrote pre-commit?? 😮
For applications would you consider using a pyproject.toml as standard for putting all requirements into one place (and the file can be used to configure other aspects) to reduce requirements file bloat?
no I would not -- did you watch the video? I showed my application setup as well
Any reason you forego pyproject.toml completely? Or just historical inertia?
Very useful ,thans
But, what if I don't have tests because I write flawless code the first time?
couldn't be me
Speaking of favoring single files why not get rid of tox.ini and just incorporate into setup.cfg?
they have different interpolation modes
would be curious to know what the behavioral differences are then between setup.cfg and tox.ini. Other than cosmetic [tox:tox] in setup.cfg vs [tox] in tox.ini for example.
well for starters tox uses curly braces and setuptools uses % substitution and there's a lot of situations where one breaks the other. it's some of the motivation for using an actual structured data format (toml / etc.)
If you dont pin dependencies for libraries, doesnt that mean that when you later clone a repo, you cant run it, because you wont knoe what dependencies you need to pip install?
pinning means ==, the dependencies are still listed
For a single file library, isn't it possible to include `ty.typed` via the `[options.package_data]` section entry `astpretty = py.typed` ?
it is not, try it
How do you version, tag, package and release?
ruclips.net/video/Gre2W5z4iLE/видео.html
any updates since this upload?
still the same!
Hello sir kindly would you consider relicensing all of your projects under the B0RK V1000 license
is it a derivative of the WTFPL?
@@anthonywritescode no, it's a derivative of Yu-Gi-Oh
In a single-file project with just a single test file at the root level, how do you exclude that test file from mypy?
I don't do that, but it's not different from what I show in the video
@@anthonywritescode It is different in that your tests aren't typed. So you tell mypy to ignore the whole tests/ dir. Just wondering how to do that for single files. This doesn't work
[mypy-test_file_name]
disallow_untyped_defs = false
works fine for me, you must have a typo
How do you run the code in the application project without installing it? By modifying PYTHONPATH? Or is it always single files that can be run as scripts?
`PYTHONPATH` is always wrong, and scripts are almost always wrong -- use `python -m module.name`
@@anthonywritescode Gotcha, thanks! I'm still wondering how one would deal with multiple source files and imports. E.g. if I have app/x.py and app/y.py running python -m app.x works, but writing "import y" in x.py doesn't. How would one go about structuring this?
always use absolute imports to import `app/y.py` you'd use `app.y` as your import
@@anthonywritescode that does the job, thanks :)
Hey Anthony, why did you stop using vim?
I never used vim