flake8

Flake8 reports E999 SyntaxError

Flake8 reports E999 SyntaxError Question: I am unable to solve the flake8 SyntaxError and although the code executes just fine. Code without comments import math def answer(str_n): sume = ((str_n * (str_n + 1)) / 2) * math.sqrt(2) sume = int(sume) return sume def answer1(str_n): sume = 0 for i in range(str_n + 1): sume …

Total answers: 2

Per-project flake8 max line length?

Per-project flake8 max line length? Question: I’m using a Flake8 git hook in my project and I want to relax the line length limit, but only for one project. Given that it looks like there’s no clear API for that, how do I modify this hook to do that? Alternatively, is there a git-config setting …

Total answers: 1

python pep8 class in init imported but not used

python pep8 class in init imported but not used Question: I’m doing PEP8 checks in python using the python flake8 library. I have an import statement in an __init__.py file in one of my sub-modules which looks like this: from .my_class import MyClass The reason I have this line in the init file is so …

Total answers: 3

E731 do not assign a lambda expression, use a def

E731 do not assign a lambda expression, use a def Question: I get this pep8 warning whenever I use lambda expressions. Are lambda expressions not recommended? If not why? Asked By: Kechit Goyal || Source Answers: The recommendation in PEP-8 you are running into is: Always use a def statement instead of an assignment statement …

Total answers: 5

How to use flake8 for Python 3 ?

How to use flake8 for Python 3 ? Question: 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 7.3.py -vv checking 7.3.py def add(x: int, y: int) -> int: return …

Total answers: 6

flake8 complains on boolean comparison "==" in filter clause

flake8 complains on boolean comparison "==" in filter clause Question: I have a boolean field in the mysql db table. # table model class TestCase(Base): __tablename__ = ‘test_cases’ … obsoleted = Column(‘obsoleted’, Boolean) To get the count of all the non-obsoleted test cases, that can be done simply like this: caseNum = session.query(TestCase).filter(TestCase.obsoleted == False).count() …

Total answers: 6