How to use flake8 for Python 3 ?

In this code snippet, def add(x:int, y:int) -> int: return x + y there are function annotations that are only supported after python 3.0 When I execute flake8 for this python code: $ flake8...

Python3, flake8 - File type annotation

Trying to annotate a file in my function there is the following issue with my pep8-checker (flake8): def my_function(myfile: file): pass gives 'undefined name file' . Fair enough - there is...

Flake 8: "multiple statements on one line (colon)" only for variable name starting with "if"

I'm using flake8 in Visual Studio Code, writing some code using Python 3.6 variable annotations. It worked without any problems so far, but I encountered a strange warning. This works fine: style:...

How to make Django, type annotations, and Flake8 work together?

I'm using Django / DRF. I want to write type-checked Python. I also want linting. Django's model structure involves creating a manager class for every model, and assigning an instance of the...

Automatic code checking for python works incorrect

I try to check my code using special configuration .pre-commit-config.yaml repos: - repo: https://github.com/ambv/black rev: 'stable' hooks: - id: black args: [--py36,...

Python PEP8: Ignore single import on multi-line import

I have the following import in my python code: from apps.balance.models import BLOCKED, CREDIT, TRIAL, TrialAlert But PEP8/flake8 tells my that TrialAlert is not used. In the code itself, it...

Why is the mypy FAQ mentioning performance impact?

As far as I understood, mypy is a tool that will check python code that includes type annotations. However, in the FAQ, I read the following: Mypy only does static type checking and it does not...

How to have a better code to pass the pre-commit check?

I have such code in python 3.7, as : try: import json except ImportError: import simplejson as json And once I am running pre-commit, I have received such failure: testcase.py:57:...

How can I produce github annotations by creating report files on disk?

I am trying to find a portable way to produce code annotations for GitHub in a way that would avoid a vendor-lockin. Mainly I want to dump annotations inside a file (yaml, json,...) during build...

Syntax Error with flake8 and Pydantic Constrained Types: constr(regex=)

I use in Python the package pydantic and the linker Flake8. I want to use constr from pydantic with a regular Experssion. Only certain Characters should be passed. (a-z, A-Z, 0-9 and _) The...