Timnology
Timnology
  • 4
  • 23 360
Create a modern pre-commit setup for Python using UV, Ruff and more
This video shows how to create a solid pre-commit setup for Python.
Previous video containing the CI pipeline: ua-cam.com/video/Y6D2XaFV3Cc/v-deo.html
The repo is available at github.com/timvancann/yt-python-ci
Write up is available at www.timnology.io/articles/python-pre-commit
Buy me a coffee: buymeacoffee.com/timvancann
Pre-commit: pre-commit.com/
#code #python #tutorial #education #cicd #uv #ruff #pyright #precommit
00:00:00 Intro
00:00:26 Goal
00:00:45 Installation
00:01:24 Lock file
00:02:01 Running the CLI
00:02:51 Ruff
00:03:00 Pyright
00:03:34 Tests
00:04:33 Outro
Переглядів: 1 804

Відео

Setup a modern Python Code Quality CI Pipeline using UV, Ruff and more
Переглядів 3,9 тис.2 місяці тому
This video shows how to setup a modern CI Pipeline using various tools such as UV, Ruff, Pytest and Pyright. A write-up is available at: www.timnology.io/articles/python-ci The repo is available at github.com/timvancann/yt-python-ci Buy me a coffee: buymeacoffee.com/timvancann #code #python #tutorial #education #cicd #uv #ruff #pyright 00:00:00 Intro 00:00:18 Initialisation 00:00:35 Lock file 0...
UV - A modern python project and dependency manager
Переглядів 15 тис.4 місяці тому
This video showcase the latest features of UV after their impressive blogpost: astral.sh/blog/uv-unified-python-packaging A write-up is available at: www.timnology.io/articles/uv Buy me a coffee: buymeacoffee.com/timvancann #code #python #tutorial #education 00:00 Intro 00:28 Installation 00:45 Initialization 01:07 Adding dependencies 01:37 Running commands 03:24 Installing python 04:15 Speed t...
Master the python logging module
Переглядів 3 тис.4 місяці тому
This video gives insight into the python logging module. Master handers, filters, formatters, log hierarchy and log configuration. A write-up is available at www.timnology.io/articles/python-logging Buy me a coffee: buymeacoffee.com/timvancann #python #code #tutorial #education 0:00 Intro 0:18 Logger 0:28 LogLevels 1:04 Handlers 1:42 Handler loglevel 2:07 Handler formatter 2:55 LastResort handl...

КОМЕНТАРІ

  • @viakondratiuk
    @viakondratiuk Годину тому

    Thank you! Fantastic. Just was playing around with it and it was not working for me. Found your video and it helped :)

    • @viakondratiuk
      @viakondratiuk Годину тому

      Have you considered adding mypy as well?

  • @john-schumandr
    @john-schumandr 8 днів тому

    wait, it installing interpreter inside of .env ?

    • @Timnology-r4s
      @Timnology-r4s 7 днів тому

      UV reserves a folder within your home directory to store all python versions and links the env to that location. You have quite a bit control over this: docs.astral.sh/uv/guides/install-python/

  • @josephk.9567
    @josephk.9567 11 днів тому

    interestingly changing python version from the pyproject.toml and then running "uv sync" does not update the venv python version for me (windows user). I have to manually run "uv venv --python 3.x" and then rerun "uv sync" to reinstall the libraries

  • @al76am8
    @al76am8 15 днів тому

    Please create more videos man!!!

  • @al76am8
    @al76am8 15 днів тому

    I was trying to do thesame task for more than week... building python software into packages is crap! UV makes it much more pleasent. Thanks for the video.

  • @IshaqKhan010
    @IshaqKhan010 15 днів тому

    Can make video on pants compared to uv please please

  • @Proprogrammer001
    @Proprogrammer001 16 днів тому

    What a gem!

  • @SalahSaoud-j5s
    @SalahSaoud-j5s 18 днів тому

    Thank you so much for the follow up video. Another fantastic video. Could you please share your thoughts on the tools and ways to document your python projects.

    • @Timnology-r4s
      @Timnology-r4s 18 днів тому

      To document the project I typically use www.mkdocs.org/ and use a CI pipeline to push it to a static website provider such as azure.microsoft.com/en-us/products/app-service/static. Alternatively you can host static websites on most cloud storages such as GCP Buckets, Amazon S3 and Azure Storage Accounts.

  • @yorailevi6747
    @yorailevi6747 19 днів тому

    I love it a lot! 2 questions. 1) will you update the website to add pre-commit instruction? 2) the pre-commit versioned hooks aren't updated to stay in sync if pyproject.toml version are updated, do you have any idea how to keep the pre-commit and local project tooling on the same version? example: pyright recently complained: ``` WARNING: there is a new pyright version available (v1.1.387 -> v1.1.390). Please install the new version or set PYRIGHT_PYTHON_FORCE_VERSION to `latest` ``` which requires updating both files

    • @Timnology-r4s
      @Timnology-r4s 18 днів тому

      1. Oh dang, thanks for the heads-up. I forgot to hit publish, the website is updated with the write-up now :). 2. There are a few ways to go about that, one way is to simply not update to the latest version unless you're missing features or run into bugs. A second is to indeed do it manually, for small projects that is usually fine. Lastly, the more mature option is to use automated systems such as docs.renovatebot.com/ which what I typically use. It supports UV, lock files AND pre-commit!

  • @vincentjean6756
    @vincentjean6756 22 дні тому

    Thanks for that!

  • @it_is_ni
    @it_is_ni 23 дні тому

    @0:44 just so you know: some of the characters in the icons are a lot closer together than the others, looks kinda weird. Maybe a kerning setting in the tool you're using to generate those?

    • @Timnology-r4s
      @Timnology-r4s 18 днів тому

      Thanks, now I can't unsee that, didn't notice it before :p. I use www.manim.community/ for the animations. I'll have a look if it does something weird with the kerning for non build-in fonts.

  • @modoudiao9660
    @modoudiao9660 24 дні тому

    Thanks for sharing ❤️

  • @kurtke1990
    @kurtke1990 25 днів тому

    Thank you for sharing. This helps a lot.

  • @Aristocle
    @Aristocle 29 днів тому

    Is there a particular reason why the pre-commit file is inside the tests folder? and not in the project root. Also, I believe the pyproject.toml file is in the tests folder just to run this specific example? Could you also give an example for gitlab?

    • @Timnology-r4s
      @Timnology-r4s 29 днів тому

      Both files are in the root. Perhaps they appear to be in the tests folder because of the right pointing chevron, but they are siblings. See the repo: github.com/timvancann/yt-python-ci. Pre-commit hooks are fully independent of CI provider, so this setup will work fine for gitlab as well.

  • @alejandroulisessanchezgame6924
    @alejandroulisessanchezgame6924 Місяць тому

    Can u share your nvim config, or make a video about it ? 🙏

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      In this video I'm using IntelliJ, but in others I'm using neovim. I'll have a think in how to showcase how I've setup my dev environment..

  • @Aristocle
    @Aristocle Місяць тому

    what do you think about loguru?

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      I do not have enough experience with loguru to give an education opinion. I think it works really well to hide a lot of boilerplate from the default module and gives a TON of options. However, I've never had the need for such a setup, even in enterprise code bases. Colors and such a great if you keep reading the output in a console, but in a more streamlined setup logs are usually gathered/pushed to an external service such a sentry, datadog, Azure Log Analytics, AWS Cloudwatch, GCP Cloud Logging or equivalent services. With a good alerting setup you only need to query and search the logs when something breaks.

    • @Aristocle
      @Aristocle Місяць тому

      @@Timnology-r4s Yes. The thing that is important to me is to avoid writing useless code and reading the docker console output in the early stages of deploy.

  •  Місяць тому

    Your videos are amazing.

  •  Місяць тому

    Great video! Would you consider making a video about your PyCharm settings? Your setup looks minimalist, similar to my VSCode, and I’m interested in migrating from VSCode to PyCharm. I’ve customized a lot of settings in VSCode, but I’d like to learn more about PyCharm and its benefits. I've tried adjusting some settings and the UI to resemble yours, but I couldn’t quite get it right. I’d also love to know about integrations with tools like Ruff and Pyright in PyCharm and how they work together.

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      Thanks for the suggestions. I'll have a think on how to structure such a video! To quickly get what was shown in the video you can install the catppuccin color scheme. The cleanliness mostly comes from enabling view -> appearance -> Presentation Mode. Distraction Free mode also works really well to hide a lot of UI elements.

    •  Місяць тому

      ​@@Timnology-r4s Thanks i will check!

  • @timothyspottering
    @timothyspottering Місяць тому

    You are really motivating me to introduce a CI / CD pipeline for my python startup development! Every of your videos is like a friendly reminder, that I should be doing that.

  • @sglbl
    @sglbl Місяць тому

    Thank you. One suggesstion; When you share the screen, there should be some space at the bottom of terminal text input place so that when we pause the video, youtube's bar will not block the input and we will still be able to see the input.

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      Good suggestion! I've incorporated that into my new video!

  • @AJXD2
    @AJXD2 Місяць тому

    Its lowkey hard to tell that you have 600 subs. I got to 4:00 before I looked down by accident and saw it. Keep it up!

  • @porlando12
    @porlando12 Місяць тому

    Amazing video! This channel is criminally underrated. It would be cool to see how you would migrate an existing project managed via poetry over to using uv in a future video!

  • @eboyd53
    @eboyd53 Місяць тому

    What IDE are you using?

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      I wouldn't call it an IDE though it comes close to one: in this video I use neovim, with the astronvim.com/ distribution. Typically I use JetBrains IntelliJ for my day to day job.

  • @kamurashev
    @kamurashev Місяць тому

    Cough npm cough… it might be good the only thing it must be adopted as a language standard first

  • @williansuarez3988
    @williansuarez3988 Місяць тому

    ¡Excelente! aunque no entendí todo ¿que puedo hacer para aprender y llegar a ese nivel?

  • @froozynoobfan
    @froozynoobfan Місяць тому

    just working on my own package, any reason you did not use "uv build"?

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      I see I made a boo Boo there. I wrote the repo before uv added a build backend, but recorded the video after they did. So the cli command uses `uv build`, but the CI uses `uv run build`. It should be `uv build` everywhere. Good catch!

  • @zuowang5185
    @zuowang5185 Місяць тому

    Is it fast on cold CI start? Does it generate cross platform lockfile?

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      Yes it is fast. If not fast enough you can enable caching: github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching Yes, the lock file is cross platform compatible.

  • @tomasemilio
    @tomasemilio Місяць тому

    High quality videos, congratulations!

  • @7006608
    @7006608 Місяць тому

    Tip: vertical flip your head video to point to the screen instead off screen thanks for the video!

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      Oh snap, that's a good tip. I've never even thought about that!

  • @this-is-bioman
    @this-is-bioman Місяць тому

    It does not look like any kind of breakthrough. Just another package manager on top of an existing one with even more new commands to learn.

  • @tomasemilio
    @tomasemilio Місяць тому

    works great, but my lsp is complaning when i install other packages, as though they weren't installed

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      99% chance your lsp is using the wrong interpreter. If you use neovim (or zed, or helix), there are plugins that allow you to easily switch venv, but what I found works great is: uv run nvim . That automatically launches vim with the correct venv. In vscode no clue, you probably have to setup a python interpreter by pointing to the .venv/bin/python script. The same holds true for Jetbrains products.

    • @tomasemilio
      @tomasemilio Місяць тому

      @@Timnology-r4s hero! haha amazing and yeah that is it. i will slowly transition to UV, it really looks amazing.

  • @bigoper
    @bigoper Місяць тому

    New SUB here Just flawless ❤

  • @SalahSaoud-j5s
    @SalahSaoud-j5s Місяць тому

    Wonderful video. Just one question. In order to format and apply the fixes before commits, do you run each ruff, pytest, pyright ... commands manually or do you use some other tools like Tox?

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      Good question! Perhaps I should do a video about that as well. I typically setup a solid pre-commit hook that does all that, as well as making sure my editor does formatting on auto-save.

    • @SalahSaoud-j5s
      @SalahSaoud-j5s Місяць тому

      @@Timnology-r4s That would be a great follow up video for this one. I look forward for that. Thanks again for the great videos.

  • @juvewan
    @juvewan Місяць тому

    A great video for using uv in CI. Do you use uv in pre commit hooks or in IDE? I am trying to automate python code formatting, so IDE and/or pre-commit hooks can take care of it, and CI won't complain about formatting error.

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      Good question. I use both. For neovim none-ls with ruff, and in IntelliJ with the ruff plugin. This takes care of auto formatting on save. Pre-commit books are there to verify and pick up anything that the IDE missed (as well as doing a bunch of other things, like running tests)

    • @juvewan
      @juvewan Місяць тому

      @@Timnology-r4s thank you!

  • @guidyouguy7306
    @guidyouguy7306 Місяць тому

    Poetry does the same thing

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      Some of it, yes. Though poetry isn't fully PEP compliant and is significantly slower on large projects.

  • @noopurp123
    @noopurp123 Місяць тому

    What terminal are you using there?

  • @felipeadeildo
    @felipeadeildo Місяць тому

    A thing that I really like at using poetry as my project dependency manager is that it's create the virtual environment folder outside the project, that's really a cool function So, how can I do the same thing with UV? I noticed that is has been created a .venv folder at the root project...

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      Personally, I really like having the .venv folder right where the code lives. However, uv does give you the option to specify a custom folder: docs.astral.sh/uv/pip/environments/#creating-a-virtual-environment

  • @Anh_AI
    @Anh_AI Місяць тому

    Sir, 2 Q that I want to ask: 1. How can train/run Yolo with GPU (that Pytorch only install with pip?) 2. How to build uv python app to exe?

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      1. I never work with pytorch, but this github issue seems to have a solution running on GPU: github.com/astral-sh/uv/issues/7202#issuecomment-2447539317. 2. To get a python exe you can use pyinstaller.org/en/stable/. A simple `uv add --dev pyinstaller ` and `uv run pyinstaller` would do the trick :)

  • @tridibbiswas3361
    @tridibbiswas3361 Місяць тому

    Thank you for your video. I am newbie and learning. This was really helpful. Also, if you don’t mind a trivial ask , I liked your font and color scheme- could you share the names

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      Glad you found it useful. All questions are welcome! I use the open source Jetbrains Mono Nerd font (www.nerdfonts.com/font-downloads), and Catppuccin Mocha color scheme (catppuccin.com/)

  • @mrttsmn
    @mrttsmn Місяць тому

    Well this looks great but do i need to manually update and manually manage dependencies for every uv version?

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      Not precisely, like with requirements.txt, or Poetry, you need to manage your dependencies per project. The version of uv you are running doesn't matter. UV is there to resolve the complicated dependency tree that is pip.

  • @timothyspottering
    @timothyspottering Місяць тому

    Good content!

  • @timothyspottering
    @timothyspottering Місяць тому

    This was a great video. I understand now, why you should maybe use uv in python projects

  • @rosslote1895
    @rosslote1895 Місяць тому

    I'm following this exactly and locally --locked is fine but when I trigger the action it fails. Any ideas? All of my code is commited and pushed

    • @rosslote1895
      @rosslote1895 Місяць тому

      I change the version of astral-sh/setup-uv@v3 to latest and it fixed the issue. Great content by the way.

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      Glad you found the fix!

  • @1Docflash
    @1Docflash Місяць тому

    lol. may be great tool but i followed your directions and only get error messages. bummer glad it worked for other people

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      What kind of error messages did you get?

  • @jarrettbullion1545
    @jarrettbullion1545 Місяць тому

    partly why your dependencies installed so quick is because they are cached on your machine.

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      That is correct, though even after removing the cache the installation is single digit seconds. The power of UV really shines in its completeness as a tool, PEP compliancy and lightning fast dependency resolution.

  • @DataScienceandAI-doanngoccuong
    @DataScienceandAI-doanngoccuong Місяць тому

    tui thấy giống npm install (package.js) trong javaScripts.

  • @djpaulytee
    @djpaulytee Місяць тому

    Hi Tim, interesting video. What is the plugin you are using for the popup terminal?

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      It's the build in terminal In astronvim: toggleterm (github.com/akinsho/toggleterm.nvim)

  • @erfan_ops
    @erfan_ops Місяць тому

    i was expecting to see a 'K' by the subscribers count

  • @samjiman
    @samjiman 2 місяці тому

    Most of my Python code only uses the standard library (theres a heck of a lot you can do with those batteries) and a lot of modules I prefer to implement my own classes/functions. Might try with my Flask apps though or maybe if I made some of my stuff libraries on PIP.

  • @EmersonArenas-n1v
    @EmersonArenas-n1v 2 місяці тому

    fantastic video, can you make a video of Granian and Rust based frameworks?

    • @Timnology-r4s
      @Timnology-r4s Місяць тому

      Thank you! I'm not planning on doing a lot of lower level videos, if anything it's going to be a video of FastAPI which used Granian under the hood as ASGI framework.