Skip to main content

Intro

We use Python 3.9 or higher in all of our projects. We believe that using the latest version of Python provides us with access to the newest features and tools that can enhance our development process.

PEP 484 for Type Hints

We use PEP 484 to annotate our Python code with type hints. Type hints make it easier to read, understand and maintain code, especially in larger codebases. They also enable us to use tools like mypy to catch type errors before runtime. By using type hints, we ensure that our code is more predictable and less prone to runtime errors.

Black for Formatting

We use Black as our code formatter to ensure that our code is consistently formatted and easy to read. Black is an opinionated formatter that automatically formats code according to a set of predefined rules. By using Black, we can avoid unnecessary debates about formatting and focus on writing code.

Mypy for Type Checking

We use mypy to check our code for type errors. Mypy is a static type checker that can analyze our code and find errors before runtime. By using mypy, we can catch errors early in the development process and reduce the amount of time spent debugging code.

Linting and Type Checking with Black and Mypy

To use Black and mypy in our projects, we can install them using pip (please refer to package managers):

In conclusion, coding standards are an essential part of software development, and TypeScript is no exception. At Figuro, we use a set of coding standards that have proven to be effective in ensuring that our TypeScript code is of the highest quality. By using these standards, we are able to catch errors early, improve code quality, and ensure that our code is readable and maintainable.

pip install black mypy

After installation, we can use Black to format our code by running the following command:

black my_module.py

This will format the code in my_module.py according to Black's rules.

To use mypy to check for type errors, we can run the following command:

mypy my_module.py

This will analyze my_module.py and report any type errors that it finds.

tip

By using Python 3.9 or higher, PEP 484 for Type Hints, Black and mypy, we ensure that our Python code is consistent, readable, and less prone to errors. These tools and guidelines have become industry standards, and using them helps us to produce high-quality code that is easy to maintain and understand.

Resources

If you want to learn more about Python coding standards and best practices, check out these resources: