A Tale of Two Kitchens - Hypermodernizing Your Python Code Base

This page summarizes the projects mentioned and recommended in the original post on dev.to

Scout Monitoring - Free Django app performance insights with Scout Monitoring
Get Scout setup in minutes, and let us sweat the small stuff. A couple lines in settings.py is all you need to start monitoring your apps. Sign up for our free tier today.
www.scoutapm.com
featured
CodeRabbit: AI Code Reviews for Developers
Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
coderabbit.ai
featured
  • absolufy-imports

    Discontinued Automatically convert relative imports to absolute

    absolufy-imports converts relative imports to absolute ones.

  • Scout Monitoring

    Free Django app performance insights with Scout Monitoring. Get Scout setup in minutes, and let us sweat the small stuff. A couple lines in settings.py is all you need to start monitoring your apps. Sign up for our free tier today.

    Scout Monitoring logo
  • removestar

    Tool to automatically replace 'import *' in Python files with explicit imports

    removestar replaces import * in Python files with explicit imports.

  • unimport

    Discontinued :rocket: The ultimate linter and formatter for removing unused import statements in your code. [Moved to: https://github.com/hakancelikdev/unimport] (by hakancelik96)

    unimport: removes unused imports.

  • pyre-check

    Performant type-checking for python.

    Pyre from Meta, pyright from Microsoft and PyType from Google provide additional assistance. They can 'infer' types based on code flow and existing types within the code.

  • black

    Discontinued The uncompromising Python code formatter [Moved to: https://github.com/psf/black] (by python)

    To get all your code into a consistent format the next step is to run a formatter. I recommend black, the well-known uncompromising code formatter, which is the most popular choice. Alternatives to black are autoflake, prettier and yapf, if you do not agree with blacks constraints.

  • isort

    A Python utility / library to sort imports.

    isort will sort the imports for you

  • autoflake

    Discontinued Removes unused imports and unused variables as reported by pyflakes [Moved to: https://github.com/PyCQA/autoflake] (by myint)

    To get all your code into a consistent format the next step is to run a formatter. I recommend black, the well-known uncompromising code formatter, which is the most popular choice. Alternatives to black are autoflake, prettier and yapf, if you do not agree with blacks constraints.

  • CodeRabbit

    CodeRabbit: AI Code Reviews for Developers. Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.

    CodeRabbit logo
  • pre-commit

    A framework for managing and maintaining multi-language pre-commit hooks.

    Pre-commit Hooks: Pre-commit is a tool that can be set up to enforce coding rules and standards before you commit your changes to your code repository. This ensures that you can't even check in (commit) code that doesn't meet your standards. This allows a code reviewer to focus on the architecture of a change while not wasting time with trivial style nitpicks.

  • prettier

    Prettier is an opinionated code formatter.

    To get all your code into a consistent format the next step is to run a formatter. I recommend black, the well-known uncompromising code formatter, which is the most popular choice. Alternatives to black are autoflake, prettier and yapf, if you do not agree with blacks constraints.

  • mutmut

    Mutation testing system

    Mutmut introduces a clever approach to scrutinizing your tests. It evaluates the effectiveness of your test suite by slightly altering the code after the tests have been written. If a test fails after a minor change, that's a good sign; it means the test is robust enough to catch those changes. But if the test passes even after the code change, it indicates that the test isn't effectively detecting that alteration – this is what Mutmut terms a "surviving mutant."

  • hypothesis

    Hypothesis is a powerful, flexible, and easy to use library for property-based testing.

    Hypothesis for Property-Based Testing: Hypothesis is a Python library facilitating property-based testing. It offers a distinct advantage by generating a wide array of input data based on specified properties or invariants within the code. The perks of Hypothesis include:

  • yapf

    A formatter for Python files

    To get all your code into a consistent format the next step is to run a formatter. I recommend black, the well-known uncompromising code formatter, which is the most popular choice. Alternatives to black are autoflake, prettier and yapf, if you do not agree with blacks constraints.

  • pyupgrade

    A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language.

    pyupgrade and flynt are examples of tools that modify your code base from earlier python versions into the newest python syntax, rewriting all string formats into f-strings and similar things.

  • pytype

    A static type analyzer for Python code

    Pyre from Meta, pyright from Microsoft and PyType from Google provide additional assistance. They can 'infer' types based on code flow and existing types within the code.

  • flynt

    A tool to automatically convert old string literal formatting to f-strings

    pyupgrade and flynt are examples of tools that modify your code base from earlier python versions into the newest python syntax, rewriting all string formats into f-strings and similar things.

  • awesome-flake8-extensions

    :octocat: A curated awesome list of flake8 extensions. Feel free to contribute! :mortar_board:

    Ultimately we want to test our code with Flake8 and plugins to enforce a more consistent code style and to encourage best practices. When you first introduce flake8 or a new plug-in commonly you have a lot of violations that you can silence with a #noqa comment. When you first introduce a new flake8 plugin, you will likely have a lot of violations, which you silence with #noqa comments. Over time these comments will become obsolete because you fixed the. yesqa will automatically remove these unnecessary #noqa comments.

  • flake8-bugbear

    A plugin for Flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle.

    Bugbear is not specifically a security tool but serves as an effective guard against common coding errors and pitfalls. It pinpoints and rectifies frequent mistakes like setting a list as a default value for a parameter and cautions against such practices, enhancing code robustness.

  • bandit

    Bandit is a tool designed to find common security issues in Python code.

    On the other hand, Bandit is a dedicated security scanner designed to target critical security concerns such as SQL injection and cross-site scripting exploits. It meticulously scrutinizes the codebase to identify and alert developers about possible security breaches or vulnerabilities, thus fortifying the code against potential exploitation.

  • ruff

    An extremely fast Python linter and code formatter, written in Rust.

    A more modern alternative for flake8 is Ruff: Ruff can be used to replace Flake8 (plus a variety of plugins), isort, pydocstyle, yesqa, eradicate, pyupgrade, and autoflake, all while executing tens or hundreds of times faster than any individual tool. Ruff supports over 700 lint rules and goes beyond the responsibilities of a traditional linter, instead functioning as an advanced code transformation tool capable of upgrading type annotations, rewriting class definitions, sorting imports, and more.

  • safety

    Safety checks Python dependencies for known security vulnerabilities and suggests the proper remediations for vulnerabilities detected.

    Safety and Dependabot complement these security tools by focusing on external dependencies. Safety takes charge of examining your dependencies, ensuring they are up-to-date and free from any known vulnerabilities. Dependabot works similarly, scanning dependencies, verifying if they're current and assessing them for potential security flaws. This function is crucial as weaknesses in external dependencies can compromise the security of the entire codebase.

  • MonkeyType

    A Python library that generates static type annotations by collecting runtime types (by Instagram)

    To alleviate the burden of manual annotation, MonkeyType offers a clever solution. It dynamically observes the types entering and leaving functions during code execution. Based on this observation, it generates a preliminary draft of type annotations. This significantly reduces the effort needed to add type hints to legacy code.

  • Schemathesis

    Supercharge your API testing, catch bugs, and ensure compliance

    SchemaThesis is a powerful tool, especially when working with web APIs, and here's how it can enhance your testing capabilities:

  • pygeoif

    Basic implementation of the __geo_interface__ 🌐️

    While most of my 'hypermodernizing' was done on proprietary code, there is a good example in pygeoif, which was brought up to the standard 10 years after the first version was released. The diff is not very helpful, almost every line was touched in the end, but you can compare the version 0.6 to the current implementation. FastKML is still actively in the process of modernizing and refactoring.

  • fastkml

    Fast 🌍️ KML processing for python

    While most of my 'hypermodernizing' was done on proprietary code, there is a good example in pygeoif, which was brought up to the standard 10 years after the first version was released. The diff is not very helpful, almost every line was touched in the end, but you can compare the version 0.6 to the current implementation. FastKML is still actively in the process of modernizing and refactoring.

  • cookiecutter-hypermodern-python

    Hypermodern Python Cookiecutter

    Hypermodern Python Cookiecutter

  • awesome-python-code-formatters

    A curated list of awesome Python code formatters

    Awesome Python Code Formatters

  • awesome-python-typing

    Collection of awesome Python types, stubs, plugins, and tools to work with them.

    Awesome Python Typing

  • awesome-python-testing

    Collection of awesome 😎️ Python resources for testing

    Awesome Python Testing

  • awesome-pytest

    A curated list of awesome pytest resources

    Awesome PyTest

  • guarddog

    :snake: :mag: GuardDog is a CLI tool to Identify malicious PyPI and npm packages

    GuardDog is a CLI tool that allows to identify malicious PyPI packages.

  • talks

    🚀️ Hypermodernizing python legacy code. Slides and links from my talks 📣️ . EuroPython 🇪🇺️ and Pycon Ireland 🇮🇪️ 2022/2023 (by cleder)

    Slides A Tale of Two Kitchens Hypermodernizing Your Codebase.

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Embracing Modern Python for Web Development

    12 projects | dev.to | 8 Dec 2023
  • Premier League Project Infrastructure Update

    4 projects | /r/dataengineering | 14 Apr 2023
  • Improve your Django Code with pre-commit

    13 projects | dev.to | 5 Apr 2023
  • How I start every new Python backend API project

    14 projects | dev.to | 19 Jan 2023
  • nbdev formating and linting

    7 projects | dev.to | 6 Jan 2023

Did you konow that Python is
the 1st most popular programming language
based on number of metions?