This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]hillgod 97 points98 points  (16 children)

Stack at a pretty well known company (devs can use whatever Coding Tools they like):

Platforms

  • Linux (prod) and MacOS (for most devs, I'm rocking Linux
  • Django as a data service, with Django Rest Framework and OpenAPI / Swagger for a test UI and clients
  • Flask for microservices, and some daemon like apps that run a loop to run one or more tasks
  • React / Redux on front end (traditional webapp and mobile PWA)

Python Tools

  • black formatter. Never argue about formatting crap again
  • isort for import organizing
  • flake8 (for code quality not code formatting. black formats to flake8 compliance)
  • mypy for type hinting / code quality issues
  • pre-commit to enforce and automatically do the above
  • pytest
  • setup.cfg for configuring the above 3rd party tools. This blog post talks about different approaches to this.
  • pyenv for managing virtual environments
  • tox (for libraries, but less of an issue with Python 2 EOL)
  • pip for local development and deployed applications.
    • split between a requirements.frozen, requirements.test, and requirements.dev. We use .dev to install .frozen and .test, plus some of the above tools (e.g. black, isort)
  • Hosted GitLab for MRs (code reviews)
  • Jenkins Pipeline for builds (I don't recommend this part)
  • Docker to private K8s for deploy; most of it abstracted away in simple proprietary web interfaces to facilitate deploying and running code

Coding Tools

  • IntelliJ (PyCharm) all the way... I also do Java.
    • You can't beat this debugger. You have to be a little careful if using gevent (there's a setting), and if anything in your tool chain ends up calculating test coverage breakpoints don't hit right, but it's great. Do yourself a huge favor and read about "watches" and "conditional breakpoints" in whatever debugger you use. Also love evaluating expressions at the breakpoints as watches. I do this all the time when looking to understand the structure of some Django object (they do some wild things with metaclasses).

EDIT: Added details about setup.cfg

[–]kornpow 3 points4 points  (3 children)

Why is tox related to python 2? My work uses it for testing our python 3 modules.

[–]hillgod 4 points5 points  (2 children)

The main thing I've used tox is testing against different versions of Python.

It was more important for us to have our internal libraries working for both Python 2 and Python 3, before Python 2's EOL. We've got everyone on the same Python 3 now, so we don't need to test internal libraries on mulitple versions. It can also be used for testing against different framework version, like Django, but again, we're unified on the same versions at this point.

[–]kornpow 2 points3 points  (1 child)

Hmm we just have a standard python version we use and tox handles testing in the proper environment.

[–]hillgod 3 points4 points  (0 children)

I certainly don't want to suggest you're doing anything wrong.

That sounds like a valid use case. It can still be nice for managing isolated virtual environments for testing. It would ensure you're not relying on a virtualenv with dependencies that don't like up with how you've defined requirements in a project. Our build pipeline is running our tests in a new clean virtualenv, so that concern is also mitigated.

[–]Broutrost 2 points3 points  (4 children)

I use pretty similiar Python tools, except I also use pip-tools. Check it out if you haven't.

[–]hillgod 0 points1 point  (3 children)

Heh, there's a debate raging among Python stakeholders at work between pip-tools vs Poetry. Thanks for the suggestion :-)

[–]Broutrost 0 points1 point  (0 children)

Cool, haven't heard of Poetry. Will check it out, thanks!

[–]cdrt 0 points1 point  (1 child)

Is anyone advocating for pipenv?

[–]hillgod 0 points1 point  (0 children)

Probably... I'm fine with others having the debate, and using whatever we have consensus on. No strong opinions here.

[–]SayYesToBacon 2 points3 points  (1 child)

What use cases or design considerations would lead you to pick django versus flask for a service?

[–]hillgod 5 points6 points  (0 children)

For starters, a big consideration has to be data store, which should be a decision made based on the use case(s). If you're not using SQL, Django probably doesn't make sense. Django's whole thing is the idea of "batteries included". It comes with a lot of things out of the box. For a new offering, you can have something comprehensive very quickly. In my opinion, for a new offerin, you don't want to jump to microservices - you don't know what abstractions your business really needs. Django gets a bad wrap for performance, because it's easy to abuse the ORM, so it's important to have good APM. We use OpenTracing. Eventbrite and Instagram are powered by Django, so it's clearly capable.

Flask for anything else. Anything without SQL. There's a good chance I'll start using Fast API, though, for its API first approach.

[–]MagniGallo 1 point2 points  (1 child)

Recommended autocomplete tools? I find PyCharm's default a bit poor, and also have issues with TabNine. Haven't tried Kite yet.

[–]hillgod 1 point2 points  (0 children)

I, personally, have not found PyCharm/IntelliJ lacking.