Open vinay-deshmukh opened 6 years ago
flake8 doesn't have the checks that pylint has, so not sure why it was worth bringing it in discussion.
But this looks like a bug in pylint, there might be something going on with PixelArray that we don't understand.
Similar false positive occurs for pygame.Surface
.
Code:
class Wall(pygame.sprite.Sprite):
def __init__(self, x, y, width, height, color):
super().__init__()
# Create the "image" for our wall
self.image = pygame.Surface([width, height])
self.image.fill(color)
# the x and y variables become the top left corner
self.rect = self.image.get_rect()
self.rect.y = y
self.rect.x = x
Linter output: E1121:Too many positional arguments for lambda call
(on line self.image = pygame.Surface([width, height])
, col 22)
And because the opening report did it: pylint --version output:
No config file found, using default configuration
pylint 1.7.4,
astroid 1.5.3
Python 3.6.6 (default, Jun 27 2018, 13:11:40)
[GCC 8.1.1 20180531]
There's probably other Pygame false positives, since Surface
is set up in __init__.py
in a similar manner to Overlay
, Mask
, and the pygame.time
and pygame.transform
modules.
This issue occurs because pygame does:
try:
from pygame.surface import *
except (ImportError, IOError):
Surface = lambda: Missing_Function
and astroid
infers Surface
could be a lambda with no arguments.
(also surface is .so file which appears to be uninferable)
Kind of a control flow issue which is a long way off. Maybe a astroid/brain tip for pygame would be the best way to go if someone wants to write one (see https://github.com/PyCQA/astroid/tree/master/astroid/brain)
A work around would be to explictly import these classes from their submodules:
from pygame import surface
surface.Surface([1,2])
Lints correctly
Steps to reproduce
Current behavior
As mentioned I get an error at the line
As,
E1121:Too many positional arguments for lambda call
Expected behavior
There shouldn't be an error in the linter output,
I tried flake8 besides pylint, and that doesn't give an error.
pylint --version output
No config file found, using default configuration pylint 1.8.4, astroid 1.6.3 Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)]