home.social

#mypy — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #mypy, aggregated by home.social.

  1. 3 ошибки при работе с dataclasses в Python

    Dataclasses появились в Python 3.7 и быстро стали стандартом: меньше бойлерплейта, чем у обычных классов, проще, чем attrs, и не требуют зависимостей. Выглядят настолько просто, что кажется, что ломаться там нечему. Но у них есть три ловушки, которые не видны при написании. Разобрать ошибки

    habr.com/ru/companies/otus/art

    #python #типизация_Python #наследование_классов #dataclasses #mypy #ошибки_python

  2. Практики разработки на Python

    Привет, Хабр! Меня зовут Роман, я программист в команде «Гравитон» и моя задача в компании — разработка API/CLI интерфейсов и приложений на языке Python. Цель данной статьи в том, чтобы показать как через внедрение «типовых подходов» и вспомогательных библиотек/утилит очень сильно упрощается поддержка проекта в настоящем (при передаче другому человеку или разработке в команде) и в будущем (возобновили проект спустя время). Первое, что нужно сказать — проект на Python это не только сам Python , но и множество технологий используемых вместе (Git, Docker, и т.д.). В этой статье мы сконцентрируемся на самом проекте, а именно с чего начать, что прикрутить, что учитывать при разработке.

    habr.com/ru/companies/graviton

    #бэкенд #Python #uv #ruff #mypy #практики

  3. When installing dependencies, formatting code, linting it, type-checking it, and building docs with or , , , and would previously take from 2min to several more, it now takes less than 15 seconds for the whole thing, thanks to , , and .

    This is for 5 versions (3.10 to 3.15).

    The DX got much better 🥰

  4. When installing dependencies, formatting code, linting it, type-checking it, and building docs with #Poetry or #PDM, #Black, #Flake8, #Mypy and #MkDocs would previously take from 2min to several more, it now takes less than 15 seconds for the whole thing, thanks to #uv, #Ruff, #ty and #Zensical.

    This is for 5 #Python versions (3.10 to 3.15).

    The DX got much better 🥰

  5. When installing dependencies, formatting code, linting it, type-checking it, and building docs with #Poetry or #PDM, #Black, #Flake8, #Mypy and #MkDocs would previously take from 2min to several more, it now takes less than 15 seconds for the whole thing, thanks to #uv, #Ruff, #ty and #Zensical.

    This is for 5 #Python versions (3.10 to 3.15).

    The DX got much better 🥰

  6. When installing dependencies, formatting code, linting it, type-checking it, and building docs with #Poetry or #PDM, #Black, #Flake8, #Mypy and #MkDocs would previously take from 2min to several more, it now takes less than 15 seconds for the whole thing, thanks to #uv, #Ruff, #ty and #Zensical.

    This is for 5 #Python versions (3.10 to 3.15).

    The DX got much better 🥰

  7. Is there any way linter/type checker for #Python that can find expressions that never will evaluate to anything other than False based on the type information? E.g. checking if a variable of the type `int` exists within a list of the type `list[str]`? I do use #mypy but it doesn't seem to catch this.

  8. Git-хуки, которые не дают коммитить плохой код

    Здравствуйте, коллеги программисты! Большинство фейлов в CI — это мелочи: забытый console.log , форматирование, линт, сломанный импорт, файл без теста. Такие ошибки не должны доезжать до сборки или код-ревью. Git-хуки позволяют запускать проверки прямо во время git commit и блокировать коммит, если были обнаружены нарушения. В прошлой статье я рассказывал про скрипты, которые я использую для проверки качества кода в PHP/Laravel. В этой статье я хочу рассказать о скриптах для JavaScript/TypeScript и Python — линтинг, форматирование, тесты, статический анализ и проверка наличия тестов. Все скрипты описанные в статье находятся здесь - github.com/prog-time/git-hooks

    habr.com/ru/articles/993870/

    #линтер #git_hooks #javascript #python #eslint #prettier #tsc #vitest #mypy #pytest

  9. Git-хуки, которые не дают коммитить плохой код

    Здравствуйте, коллеги программисты! Большинство фейлов в CI — это мелочи: забытый console.log , форматирование, линт, сломанный импорт, файл без теста. Такие ошибки не должны доезжать до сборки или код-ревью. Git-хуки позволяют запускать проверки прямо во время git commit и блокировать коммит, если были обнаружены нарушения. В прошлой статье я рассказывал про скрипты, которые я использую для проверки качества кода в PHP/Laravel. В этой статье я хочу рассказать о скриптах для JavaScript/TypeScript и Python — линтинг, форматирование, тесты, статический анализ и проверка наличия тестов. Все скрипты описанные в статье находятся здесь - github.com/prog-time/git-hooks

    habr.com/ru/articles/993870/

    #линтер #git_hooks #javascript #python #eslint #prettier #tsc #vitest #mypy #pytest

  10. Git-хуки, которые не дают коммитить плохой код

    Здравствуйте, коллеги программисты! Большинство фейлов в CI — это мелочи: забытый console.log , форматирование, линт, сломанный импорт, файл без теста. Такие ошибки не должны доезжать до сборки или код-ревью. Git-хуки позволяют запускать проверки прямо во время git commit и блокировать коммит, если были обнаружены нарушения. В прошлой статье я рассказывал про скрипты, которые я использую для проверки качества кода в PHP/Laravel. В этой статье я хочу рассказать о скриптах для JavaScript/TypeScript и Python — линтинг, форматирование, тесты, статический анализ и проверка наличия тестов. Все скрипты описанные в статье находятся здесь - github.com/prog-time/git-hooks

    habr.com/ru/articles/993870/

    #линтер #git_hooks #javascript #python #eslint #prettier #tsc #vitest #mypy #pytest

  11. Git-хуки, которые не дают коммитить плохой код

    Здравствуйте, коллеги программисты! Большинство фейлов в CI — это мелочи: забытый console.log , форматирование, линт, сломанный импорт, файл без теста. Такие ошибки не должны доезжать до сборки или код-ревью. Git-хуки позволяют запускать проверки прямо во время git commit и блокировать коммит, если были обнаружены нарушения. В прошлой статье я рассказывал про скрипты, которые я использую для проверки качества кода в PHP/Laravel. В этой статье я хочу рассказать о скриптах для JavaScript/TypeScript и Python — линтинг, форматирование, тесты, статический анализ и проверка наличия тестов. Все скрипты описанные в статье находятся здесь - github.com/prog-time/git-hooks

    habr.com/ru/articles/993870/

    #линтер #git_hooks #javascript #python #eslint #prettier #tsc #vitest #mypy #pytest

  12. The only criticism I have of types in Python:

    Python is a really good dynamically typed language. Since classes are themselves instances of a class-describing object, you can do what other languages have to do with text-transforming macros by just treating the class as mutable and dynamically adding things like methods.

    ... and then the type system kicks your ass for doing that, so you're left with a few not-great options.

    #python #mypy

  13. Январский рефакторинг: 7 дней, чтобы почистить Python веб‑проект

    Январь - самое удобное время разобрать завалы в проекте. Пол‑команды ещё в отпусках, pull‑реквестов меньше, product owner'ы только вспоминают, что планировали делать в этом году - можно спокойно пройтись по коду и навести порядок. В этой статье пойдёт речь о нескольких косметических действиях, которые, с одной стороны, почти не затрагивают логику программы и не вызывают ненависти у тестировщиков, а с другой - делают код чуть приятнее и дают темы для обсуждения на бэкенд‑созвонах. Мы разложим импорты, перенесём логику из роутов в контроллеры, а из контроллеров - в репозитории и сервисы, избавимся от requirements.txt в пользу нормального менеджера зависимостей и включим mypy.

    habr.com/ru/articles/983172/

    #python #backend #refactoring #architecture #linter #mypy #litestar

  14. With high-performance #Python type checkers like #Pyright, #Pyrefly, and #ty now available, what's the value proposition of #Mypy? Is it the reference implementation? Or does Mypy still have the most features? I'm not trying to knock Mypy, I'm genuinely asking because I don't know.

  15. With high-performance #Python type checkers like #Pyright, #Pyrefly, and #ty now available, what's the value proposition of #Mypy? Is it the reference implementation? Or does Mypy still have the most features? I'm not trying to knock Mypy, I'm genuinely asking because I don't know.

  16. With high-performance #Python type checkers like #Pyright, #Pyrefly, and #ty now available, what's the value proposition of #Mypy? Is it the reference implementation? Or does Mypy still have the most features? I'm not trying to knock Mypy, I'm genuinely asking because I don't know.

  17. With high-performance #Python type checkers like #Pyright, #Pyrefly, and #ty now available, what's the value proposition of #Mypy? Is it the reference implementation? Or does Mypy still have the most features? I'm not trying to knock Mypy, I'm genuinely asking because I don't know.

  18. With high-performance #Python type checkers like #Pyright, #Pyrefly, and #ty now available, what's the value proposition of #Mypy? Is it the reference implementation? Or does Mypy still have the most features? I'm not trying to knock Mypy, I'm genuinely asking because I don't know.

  19. ty: революция в тайп-чекинге

    Всем привет! За последние пару лет компания Astral буквально разрывает Python-мир своими инструментами. Даже если вы не слышали это имя напрямую, с большой вероятностью вы уже пользовались их продуктами — ruff или uv . И это не преувеличение. И ruff , и uv сегодня фактически стали стандартом индустрии. Например, в свежем релизе PyCharm 2025.3 при создании нового проекта по умолчанию инициализируется именно окружение uv , а не привычный venv . Для open source-проекта — это очень серьёзный показатель доверия со стороны экосистемы. Открытый исходный код и массовое принятие инструментов Python-разработчиками дали Astral тот самый «кредит доверия», который компания, судя по всему, пока что уверенно оправдывает. И вот буквально на днях Astral объявили, что их новый «революционный» тайп-чекер ty переходит в стадию бета-тестирования. А если учитывать, что и uv , и ruff формально тоже всё ещё находятся в бете, то можно считать, что ty уже фактически вышел в релиз. Собственно, о нём и поговорим дальше. Если вам интересны подобные материалы — подписывайтесь на Telegram-канал «Код на салфетке» . Там я делюсь гайдами для новичков и полезными инструментами. А прямо сейчас у нас ещё и проходит новогодний розыгрыш.

    habr.com/ru/articles/979752/

    #uv #ruff #ty #mypy #type_checking #python #rust #astral

  20. 🚀🎉 Hold onto your keyboards, folks! #Astral has unleashed "ty," a lightning-fast #Python #type #checker, because, of course, we needed another one. Written in #Rust, because Python apparently wasn't fast enough for checking itself, "ty" is now in #Beta and ready to bravely enter a market already saturated with the likes of #mypy, #Pyright, and other tools you didn't know you couldn't live without. 🌪️🔧
    astral.sh/blog/ty #ty #HackerNews #ngated

  21. 🚀🎉 Hold onto your keyboards, folks! #Astral has unleashed "ty," a lightning-fast #Python #type #checker, because, of course, we needed another one. Written in #Rust, because Python apparently wasn't fast enough for checking itself, "ty" is now in #Beta and ready to bravely enter a market already saturated with the likes of #mypy, #Pyright, and other tools you didn't know you couldn't live without. 🌪️🔧
    astral.sh/blog/ty #ty #HackerNews #ngated

  22. 🚀🎉 Hold onto your keyboards, folks! #Astral has unleashed "ty," a lightning-fast #Python #type #checker, because, of course, we needed another one. Written in #Rust, because Python apparently wasn't fast enough for checking itself, "ty" is now in #Beta and ready to bravely enter a market already saturated with the likes of #mypy, #Pyright, and other tools you didn't know you couldn't live without. 🌪️🔧
    astral.sh/blog/ty #ty #HackerNews #ngated

  23. 🚀🎉 Hold onto your keyboards, folks! #Astral has unleashed "ty," a lightning-fast #Python #type #checker, because, of course, we needed another one. Written in #Rust, because Python apparently wasn't fast enough for checking itself, "ty" is now in #Beta and ready to bravely enter a market already saturated with the likes of #mypy, #Pyright, and other tools you didn't know you couldn't live without. 🌪️🔧
    astral.sh/blog/ty #ty #HackerNews #ngated

  24. I have a script called pyfix which runs mypy and ruff to

    - have strong typing
    - have a fixed and orderly import order
    - have the file always formatted in the same way
    - detect programming errors and redundancies.

    Now I am working on gitlogui (codeberg.org/harald/gitlogui) the main script of which I called glu. So I am running

    pyfix glu

    all the time, which reads funny. 😀

    #python #gitlogui #mypy #ruff #strongTyping #linting

  25. I have a script called pyfix which runs mypy and ruff to

    - have strong typing
    - have a fixed and orderly import order
    - have the file always formatted in the same way
    - detect programming errors and redundancies.

    Now I am working on gitlogui (codeberg.org/harald/gitlogui) the main script of which I called glu. So I am running

    pyfix glu

    all the time, which reads funny. 😀

    #python #gitlogui #mypy #ruff #strongTyping #linting

  26. I have a script called pyfix which runs mypy and ruff to

    - have strong typing
    - have a fixed and orderly import order
    - have the file always formatted in the same way
    - detect programming errors and redundancies.

    Now I am working on gitlogui (codeberg.org/harald/gitlogui) the main script of which I called glu. So I am running

    pyfix glu

    all the time, which reads funny. 😀

    #python #gitlogui #mypy #ruff #strongTyping #linting

  27. I have a script called pyfix which runs mypy and ruff to

    - have strong typing
    - have a fixed and orderly import order
    - have the file always formatted in the same way
    - detect programming errors and redundancies.

    Now I am working on gitlogui (codeberg.org/harald/gitlogui) the main script of which I called glu. So I am running

    pyfix glu

    all the time, which reads funny. 😀

    #python #gitlogui #mypy #ruff #strongTyping #linting

  28. I have a script called pyfix which runs mypy and ruff to

    - have strong typing
    - have a fixed and orderly import order
    - have the file always formatted in the same way
    - detect programming errors and redundancies.

    Now I am working on gitlogui (codeberg.org/harald/gitlogui) the main script of which I called glu. So I am running

    pyfix glu

    all the time, which reads funny. 😀

    #python #gitlogui #mypy #ruff #strongTyping #linting

  29. Okay, so, fans of the #TwistedFramework help me out here:

    I am mucking around with writing a simple new thing that, in order to have type annotations that aren't *completely* useless, needs to deal with the fact that Protocol and Factory aren't annotated.

    But adding annotations makes the entire framework notice that the pattern of paired-Protocol-and-Factory subclasses are inherently LSP violations, because .protocol and .factory are writable attributes and thus invariant.

    #python #mypy

  30. Okay, so, fans of the #TwistedFramework help me out here:

    I am mucking around with writing a simple new thing that, in order to have type annotations that aren't *completely* useless, needs to deal with the fact that Protocol and Factory aren't annotated.

    But adding annotations makes the entire framework notice that the pattern of paired-Protocol-and-Factory subclasses are inherently LSP violations, because .protocol and .factory are writable attributes and thus invariant.

    #python #mypy

  31. Okay, so, fans of the #TwistedFramework help me out here:

    I am mucking around with writing a simple new thing that, in order to have type annotations that aren't *completely* useless, needs to deal with the fact that Protocol and Factory aren't annotated.

    But adding annotations makes the entire framework notice that the pattern of paired-Protocol-and-Factory subclasses are inherently LSP violations, because .protocol and .factory are writable attributes and thus invariant.

    #python #mypy

  32. Okay, so, fans of the #TwistedFramework help me out here:

    I am mucking around with writing a simple new thing that, in order to have type annotations that aren't *completely* useless, needs to deal with the fact that Protocol and Factory aren't annotated.

    But adding annotations makes the entire framework notice that the pattern of paired-Protocol-and-Factory subclasses are inherently LSP violations, because .protocol and .factory are writable attributes and thus invariant.

    #python #mypy

  33. Okay, so, fans of the #TwistedFramework help me out here:

    I am mucking around with writing a simple new thing that, in order to have type annotations that aren't *completely* useless, needs to deal with the fact that Protocol and Factory aren't annotated.

    But adding annotations makes the entire framework notice that the pattern of paired-Protocol-and-Factory subclasses are inherently LSP violations, because .protocol and .factory are writable attributes and thus invariant.

    #python #mypy

  34. The pythonbuilder got a few improvements. Apart from introducing ruff as a consistent python code formatter and for linting in addition to mypy, it got a new module pbpython.py which wraps

    - ruff check
    - ruff format
    - mypy

    calls for easy use as target builders.

    codeberg.org/harald/pythonbuil

    #pythonbuilder
    #buildmachine
    #bashbuilder
    #buildsystem
    #buildtool
    #softwaredevelopment
    #programming
    #python
    #ruff
    #mypy

  35. I'm familiar with #protocol s in #Swift, but just recently discovered #protocol classes in #Python. Like in #Swift they allow for structural subtyping. Now you can require that a parameter passed to a function must conform to a given protocol and #mypy will statically check that for you. You get the best of both worlds -- the safety of static typing and the convenience of duck typing.

    peps.python.org/pep-0544/

  36. Redid my config to keep up with the times (I used many deprecated
    plug-ins, and didn't use ).

    I haven't the faintest idea what I'm doing, I just followed a tutorial, got , and a few plug-ins, and I am utterly stomped by how to set up the lsp, especially as I want to include type checking.

    The duality of is that I either get a tutorial that explains nothing and expects you to copy paste, or a manual that goes waaaay over my head.

  37. Other #PyConUS sprints this week:

    * #RAPIDSai
    * django-simple-deploy and py-bugger
    * #PyFyre, #MyPy, and #MyPyC
    * MemRay
    * #Ruff or Ty from Astral
    * #WheelNext
    * ci-test / linting-arguments-python

    Additionally there will be an "Introduction to Sprints" open space in Room 310 at 6:00 PM.

    #PyConUS2025

  38. Other #PyConUS sprints this week:

    * #RAPIDSai
    * django-simple-deploy and py-bugger
    * #PyFyre, #MyPy, and #MyPyC
    * MemRay
    * #Ruff or Ty from Astral
    * #WheelNext
    * ci-test / linting-arguments-python

    Additionally there will be an "Introduction to Sprints" open space in Room 310 at 6:00 PM.

    #PyConUS2025

  39. Other #PyConUS sprints this week:

    * #RAPIDSai
    * django-simple-deploy and py-bugger
    * #PyFyre, #MyPy, and #MyPyC
    * MemRay
    * #Ruff or Ty from Astral
    * #WheelNext
    * ci-test / linting-arguments-python

    Additionally there will be an "Introduction to Sprints" open space in Room 310 at 6:00 PM.

    #PyConUS2025

  40. Other #PyConUS sprints this week:

    * #RAPIDSai
    * django-simple-deploy and py-bugger
    * #PyFyre, #MyPy, and #MyPyC
    * MemRay
    * #Ruff or Ty from Astral
    * #WheelNext
    * ci-test / linting-arguments-python

    Additionally there will be an "Introduction to Sprints" open space in Room 310 at 6:00 PM.

    #PyConUS2025

  41. Other #PyConUS sprints this week:

    * #RAPIDSai
    * django-simple-deploy and py-bugger
    * #PyFyre, #MyPy, and #MyPyC
    * MemRay
    * #Ruff or Ty from Astral
    * #WheelNext
    * ci-test / linting-arguments-python

    Additionally there will be an "Introduction to Sprints" open space in Room 310 at 6:00 PM.

    #PyConUS2025

  42. @seungjin I write #python code every day, and type hints are a "syntactic sugar" and are not required at all from the interpreter point of view.

    For large projects, it's useful to add hints to "follow" what you are doing, and type checkers like #pyright or #mypy can help to find some bugs, by example when calling a method with wrong parameters types.

    It also help for the readability of the code.

  43. #ty #mypy - but mypy already compiles itself to c via #mypyc so being faster isn't what I'd be expecting, it will be different and probably find different typing errors since for all the type checkers, it comes down to a matter of opinion. Do you think that will be a runtime error? That's in the future, who knows man.

  44. #ty #mypy - but mypy already compiles itself to c via #mypyc so being faster isn't what I'd be expecting, it will be different and probably find different typing errors since for all the type checkers, it comes down to a matter of opinion. Do you think that will be a runtime error? That's in the future, who knows man.

  45. #ty #mypy - but mypy already compiles itself to c via #mypyc so being faster isn't what I'd be expecting, it will be different and probably find different typing errors since for all the type checkers, it comes down to a matter of opinion. Do you think that will be a runtime error? That's in the future, who knows man.

  46. #ty #mypy - but mypy already compiles itself to c via #mypyc so being faster isn't what I'd be expecting, it will be different and probably find different typing errors since for all the type checkers, it comes down to a matter of opinion. Do you think that will be a runtime error? That's in the future, who knows man.

  47. #ty #mypy - but mypy already compiles itself to c via #mypyc so being faster isn't what I'd be expecting, it will be different and probably find different typing errors since for all the type checkers, it comes down to a matter of opinion. Do you think that will be a runtime error? That's in the future, who knows man.

  48. Our of the box, is "better" than . Less configuration and more strict!

  49. Аннотации типов в Python: коротко о главном

    Привет, Хабр! Сегодня рассмотрим, как Python, оставаясь динамически типизированным, может приближаться к строгой типизации. Всё дело в аннотациях типов , которые позволяют явно указывать, какие данные ожидаются в переменных, аргументах функций и возвращаемых значениях. Аннотации сами по себе не заставляют Python проверять типы во время выполнения, но их можно использовать вместе с инструментами статического анализа. В первую очередь мы будем работать с mypy — популярным инструментом, который выявляет ошибки до запуска программы.

    habr.com/ru/companies/otus/art

    #python #аннотации_типов #строгая_типизация #mypy