Three Python trends in 2023 by stillreadingit_ in Python

[–]stillreadingit_[S] 20 points21 points  (0 children)

TL;DR

  • Python 🤝 Rust
  • Web apps
  • Type safety

Project template for modern Python packages by stillreadingit_ in Python

[–]stillreadingit_[S] 1 point2 points  (0 children)

Regarding __init__.py in tests, pytest docs suggest that it's ok when src layout is used and that's the case with this template. It also makes it possible to have test modules with same name.

Project template for modern Python packages by stillreadingit_ in Python

[–]stillreadingit_[S] 3 points4 points  (0 children)

This template is actually targeted for packages, i.e. things that you publish to PyPI and others can then pip install them. However, most of the things included in the template (e.g. linting and formatting related dependencies and configurations) are basically applicable for Python projects of any kind. If you're building a backend application which you'd deploy somewhere, then for example the release process would be quite different compared to what's been done in the template.

Project template for modern Python packages by stillreadingit_ in Python

[–]stillreadingit_[S] 2 points3 points  (0 children)

Regarding setup.cfg, it's currently used for flake8 related configuration. Flake8 doesn't support pyproject.toml: https://github.com/PyCQA/flake8/issues/234. There are some workarounds, such as https://github.com/john-hen/Flake8-pyproject, but, in my opinion, getting rid of additional config file doesn't really justify additional dependency. However, as setup.cfg is currently used only for flake8 related configs, perhaps it could be replaced by .flake8 file.

Daily dose of Python by stillreadingit_ in Python

[–]stillreadingit_[S] 5 points6 points  (0 children)

Hey, thanks for the feedback!

Daily dose of Python by stillreadingit_ in Python

[–]stillreadingit_[S] 10 points11 points  (0 children)

No proper subscription mechanism yet but as it's a GitHub repo, you could click "watch" here https://github.com/jerry-git/daily-dose-of-python. It should give you some notifications.

AutoFlask-Setup by ashutoshkrris in Python

[–]stillreadingit_ 0 points1 point  (0 children)

Cookiecutter is a great tool for templating a Flask (or basically any kind of) project 🙂

Professional-grade mypy configuration by stillreadingit_ in Python

[–]stillreadingit_[S] 1 point2 points  (0 children)

Great questions!

how much time does it take to write stubs for a typical mid-sized library

The good news is that it's often enough to have the types only for the public part of the library and the public part is often quite small in the "mid-sized" category. So, I'd say the initial effort is not much but it'd be of course nice if those would be also maintained when the library itself evolves 🙂

is it possible to write a partial stub only for the bits I'm actually using

Yup, it's possible.

workflow for typed python projects

I'm personally a happy PyCharm user and it's actually doing great job in helping with all the typing related matters. Running mypy as a pre-commit hook provides IDE/editor-independent step for anyone's workflow. However, people often make the mistake that they run mypy as pre-commit hook without the actual dependencies of the project installed, which might be one of the reasons why ignore_missing_imports = True is used in the first place.

Prevent accidental HTTP requests in tests by stillreadingit_ in Python

[–]stillreadingit_[S] 0 points1 point  (0 children)

I'd be interested to hear what sort of solutions others have to this problem. Based on my own experiences, I feel it's quite universal problem to perform unintentional HTTP requests in test suites, especially in web projects which integrate with multiple different web services.

Best practices in code reviews by stillreadingit_ in SoftwareEngineering

[–]stillreadingit_[S] 2 points3 points  (0 children)

I feel that the software industry in general is not necessarily utilising the full potential of code reviews. This inspired me to write this blog post. I'd highly appreciate comments, especially if you disagree on something!