code-analysis

What does '# noqa' mean in Python comments?

What does '# noqa' mean in Python comments? Question: While searching through a Python project, I found a few lines commented with # noqa. import sys sys.path.append(r’C:dev’) import some_module # noqa What does noqa mean in Python? Is it specific to Python only? Asked By: Ishpreet || Source Answers: Adding # noqa to a line …

Total answers: 4

Automated docstring and comments spell check

Automated docstring and comments spell check Question: Consider the following sample code: # -*- coding: utf-8 -*- """Test module.""" def test(): """Tets function""" return 10 pylint gives it 10 of 10, flake8 doesn’t find any warnings: $ pylint test.py … Global evaluation —————– Your code has been rated at 10.00/10 … $ flake8 test.py $ …

Total answers: 2

What's with the integer cache maintained by the interpreter?

What's with the integer cache maintained by the interpreter? Question: After dive into Python’s source code, I find out that it maintains an array of PyInt_Objects ranging from int(-5) to int(256) (@src/Objects/intobject.c) A little experiment proves it: >>> a = 1 >>> b = 1 >>> a is b True >>> a = 257 >>> …

Total answers: 1

How do I fix PyDev "Undefined variable from import" errors?

How do I fix PyDev "Undefined variable from import" errors? Question: I’ve got a Python project using PyDev in Eclipse, and PyDev keeps generating false errors for my code. I have a module settings that defines a settings object. I import that in module b and assign an attribute with: from settings import settings settings.main …

Total answers: 13

Tool to determine what lowest version of Python required?

Tool to determine what lowest version of Python required? Question: Is there something similar to Pylint, that will look at a Python script (or run it), and determine which version of Python each line (or function) requires? For example, theoretical usage: $ magic_tool <EOF with something: pass EOF 1: ‘with’ statement requires Python 2.6 or …

Total answers: 3