Going through the book "Python Crash Course" by Eric Matthes, I receive a warning in my vscode implementation. The warning says "Parameters differ from overridden 'update' method pylint(arguments-differ))"
I have a class that inherits from the Sprite class from pygame module. In that class, I use the update method. I double checked my implementation with what's written in the book. I cannot see that I made a mistake. Reading up the update method update() on the pygame documentation, I came to the conclusion that the method expects two input arguments, but I kind of give none to them. Hence the warning? From the documentation:
*update() call the update method on contained Sprites update(*args, *kwargs) -> None Calls the update() method on all Sprites in the Group. The base Sprite class has an update method that takes any number of arguments and does nothing.
My question is: Should I be worried about the warning? I mean, 0 arguments comply with the statement any number of arguments. See below class Bullet:
"""Bullet module"""
import pygame
from pygame.sprite import Sprite
class Bullet(Sprite):
"""A class to manage bullets fired from the ship"""
def __init__(self, ai_settings, screen, ship):
"""Create bullet object at the ship's current position"""
super().__init__()
self.screen = screen
# Create a bullet rect at (0,0) and then set correct position
self.rect = pygame.Rect(0, 0, ai_settings.bullet_width, ai_settings.bullet_height)
self.rect.centerx = ship.rect.centerx # Align bullet with ship x position
self.rect.top = ship.rect.top # Align bullet with ship nose
# Store the bullet's position as a decimal value
self.y = float(self.rect.y)
self.color = ai_settings.bullet_color
self.speed_factor = ai_settings.bullet_speed_factor
def update(self):
"""Move bullet on top of screen"""
# Update the decimal position of the bullet.
self.y -= self.speed_factor
# Update the rect position.
self.rect.y = self.y
def draw_bullet(self):
"""Draw the bullet on screen"""
pygame.draw.rect(self.screen, self.color, self.rect)