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

  Рет қаралды 21,116

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
@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
@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?
@CushTuse
@CushTuse 2 жыл бұрын
a big +1 to single quotes. black's reasoning around double quotes is some of the dumbest I've read
@matthiashomann6381
@matthiashomann6381 6 ай бұрын
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 6 ай бұрын
it is not, try it
@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 :)
@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
@teoconserv9954
@teoconserv9954 2 жыл бұрын
How do you version, tag, package and release?
@anthonywritescode
@anthonywritescode 2 жыл бұрын
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
@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
@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
@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.)
@jake115577
@jake115577 Ай бұрын
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,3 М.
Spot The Fake Animal For $10,000
00:40
MrBeast
Рет қаралды 175 МЛН
15 Python Libraries You Should Know About
14:54
ArjanCodes
Рет қаралды 377 М.
Why Agent Frameworks Will Fail (and what to use instead)
19:21
Dave Ebbelaar
Рет қаралды 31 М.
Don't Use Pip For Big Projects - Use These Instead
7:56
Isaac Harris-Holt
Рет қаралды 23 М.
how should I organize my project? (beginner) anthony explains #506
10:02
anthonywritescode
Рет қаралды 12 М.
py-spy saved our python 3.11 rollout (intermediate) anthony explains #568
13:48
Vim Tips I Wish I Knew Earlier
23:00
Sebastian Daschner
Рет қаралды 46 М.
Hack your brain with Obsidian.md
11:53
No Boilerplate
Рет қаралды 1,9 МЛН
You Can Do Really Cool Things With Functions In Python
19:47
ArjanCodes
Рет қаралды 219 М.
iPhone 16 с инновационным аккумулятором
0:45
ÉЖИ АКСЁНОВ
Рет қаралды 9 МЛН
Как распознать поддельный iPhone
0:44
PEREKUPILO
Рет қаралды 2,3 МЛН
ОБСЛУЖИЛИ САМЫЙ ГРЯЗНЫЙ ПК
1:00
VA-PC
Рет қаралды 2,4 МЛН
Самые крутые школьные гаджеты
0:49
Лазер против камеры смартфона
1:01
Newtonlabs
Рет қаралды 725 М.