my python project setup (+ all tools) (intermediate) anthony explains

  Рет қаралды 20,884

anthonywritescode

anthonywritescode

2 жыл бұрын

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/asottile
stream github: github.com/anthonywritescode
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!

Пікірлер: 49
@JohnZakaria
@JohnZakaria 2 жыл бұрын
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 😂
@jamesmunroe6558
@jamesmunroe6558 Жыл бұрын
Preach, friend! What a library of knowledge this one developer is!
@nexovec
@nexovec 2 жыл бұрын
"Hey, I wrote eveything except for the language itself, use my stuff, it's free..." legend.
@adityakumarseth8934
@adityakumarseth8934 Жыл бұрын
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.
@francesconuzzo5883
@francesconuzzo5883 2 жыл бұрын
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!
@Bryft
@Bryft 2 жыл бұрын
Great video! I've looked at your config files before, and it all now makes more sense ;-]
@leiverandres
@leiverandres Жыл бұрын
You are great! Always high value content
@hasanulislam3112
@hasanulislam3112 2 жыл бұрын
Lovely! Pretty helpful content. Learns a lot.
@brodie659
@brodie659 2 жыл бұрын
I stumbled on your channel a few weeks ago and you have amazing content. I really appreciate you sharing your setup!
@esparafucio
@esparafucio 11 ай бұрын
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.
@giovannipcarvalho
@giovannipcarvalho 2 жыл бұрын
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!
@anthonywritescode
@anthonywritescode 2 жыл бұрын
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)
@hiyadmn9damy
@hiyadmn9damy 2 жыл бұрын
Very useful ,thans
@moonman8567
@moonman8567 Жыл бұрын
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?
@anthonywritescode
@anthonywritescode Жыл бұрын
no I would not -- did you watch the video? I showed my application setup as well
@subjekt5577
@subjekt5577 Жыл бұрын
Any reason you forego pyproject.toml completely? Or just historical inertia?
@Alecor_studio
@Alecor_studio 2 жыл бұрын
Would you do a video about best practices migrating from old code to new? Example python 2 to 3 :D library dependencies?
@anthonywritescode
@anthonywritescode 2 жыл бұрын
I have a whole playlist about 2-to-3, though it's kind of old: kzbin.info/aero/PLWBKAf81pmOZOukFi2KyQJ7QMNDzcq2yT
@StanislavSchmidt1
@StanislavSchmidt1 2 жыл бұрын
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?
@anthonywritescode
@anthonywritescode 2 жыл бұрын
`PYTHONPATH` is always wrong, and scripts are almost always wrong -- use `python -m module.name`
@StanislavSchmidt1
@StanislavSchmidt1 2 жыл бұрын
@@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?
@anthonywritescode
@anthonywritescode 2 жыл бұрын
always use absolute imports to import `app/y.py` you'd use `app.y` as your import
@StanislavSchmidt1
@StanislavSchmidt1 2 жыл бұрын
@@anthonywritescode that does the job, thanks :)
@matthiashomann6381
@matthiashomann6381 5 ай бұрын
For a single file library, isn't it possible to include `ty.typed` via the `[options.package_data]` section entry `astpretty = py.typed` ?
@anthonywritescode
@anthonywritescode 5 ай бұрын
it is not, try it
@teoconserv9954
@teoconserv9954 Жыл бұрын
How do you version, tag, package and release?
@anthonywritescode
@anthonywritescode Жыл бұрын
kzbin.info/www/bejne/faPIY4prr5mcgqc
@jrib
@jrib 2 жыл бұрын
In a single-file project with just a single test file at the root level, how do you exclude that test file from mypy?
@anthonywritescode
@anthonywritescode 2 жыл бұрын
I don't do that, but it's not different from what I show in the video
@jrib
@jrib 2 жыл бұрын
​@@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
@anthonywritescode
@anthonywritescode 2 жыл бұрын
works fine for me, you must have a typo
@ArielVolovik
@ArielVolovik 8 ай бұрын
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?
@anthonywritescode
@anthonywritescode 8 ай бұрын
pinning means ==, the dependencies are still listed
@b_0rk
@b_0rk 2 жыл бұрын
Hello sir kindly would you consider relicensing all of your projects under the B0RK V1000 license
@anthonywritescode
@anthonywritescode 2 жыл бұрын
is it a derivative of the WTFPL?
@b_0rk
@b_0rk 2 жыл бұрын
@@anthonywritescode no, it's a derivative of Yu-Gi-Oh
@hunnydoh
@hunnydoh 2 жыл бұрын
Speaking of favoring single files why not get rid of tox.ini and just incorporate into setup.cfg?
@anthonywritescode
@anthonywritescode 2 жыл бұрын
they have different interpolation modes
@hunnydoh
@hunnydoh 2 жыл бұрын
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.
@anthonywritescode
@anthonywritescode 2 жыл бұрын
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.)
@DavidDellsperger
@DavidDellsperger 2 жыл бұрын
But, what if I don't have tests because I write flawless code the first time?
@anthonywritescode
@anthonywritescode 2 жыл бұрын
couldn't be me
@CushTuse
@CushTuse 2 жыл бұрын
a big +1 to single quotes. black's reasoning around double quotes is some of the dumbest I've read
@jake115577
@jake115577 25 күн бұрын
You wrote pre-commit?? 😮
@longstoryveryshort
@longstoryveryshort 2 ай бұрын
any updates since this upload?
@anthonywritescode
@anthonywritescode 2 ай бұрын
still the same!
@MrHaste12
@MrHaste12 2 жыл бұрын
Hey Anthony, why did you stop using vim?
@anthonywritescode
@anthonywritescode 2 жыл бұрын
I never used vim
python can import from zips! (intermediate) anthony explains #397
5:54
anthonywritescode
Рет қаралды 2,2 М.
That's how money comes into our family
00:14
Mamasoboliha
Рет қаралды 9 МЛН
THEY WANTED TO TAKE ALL HIS GOODIES 🍫🥤🍟😂
00:17
OKUNJATA
Рет қаралды 21 МЛН
what are python wheels? (intermediate - advanced) anthony explains #371
22:47
How To Structure A Programming Project…
19:00
Tech With Tim
Рет қаралды 88 М.
a python plugin system via entrypoints (intermediate) anthony explains #128
15:04
Don't Use Pip For Big Projects - Use These Instead
7:56
Isaac Harris-Holt
Рет қаралды 22 М.
Setup a Python project with PDM
12:22
Orchard Dweller
Рет қаралды 4,2 М.
what is coverage? (intermediate) anthony explains #480
13:13
anthonywritescode
Рет қаралды 4 М.
ПОКУПКА ТЕЛЕФОНА С АВИТО?🤭
1:00
Корнеич
Рет қаралды 3,7 МЛН
Опять съемные крышки в смартфонах? #cmf
0:50
Урна с айфонами!
0:30
По ту сторону Гугла
Рет қаралды 8 МЛН
Samsung Galaxy 🔥 #shorts  #trending #youtubeshorts  #shortvideo ujjawal4u
0:10
Ujjawal4u. 120k Views . 4 hours ago
Рет қаралды 2,8 МЛН
Samsung Galaxy Unpacked July 2024: Official Replay
1:8:53
Samsung
Рет қаралды 6 МЛН