pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.32k stars 1.14k forks source link

I am working on snake game and got this error. #7849

Closed Hakanbkl closed 1 year ago

Hakanbkl commented 1 year ago

Bug description

Ekran görüntüsü 2022-11-25 203953 I entered the text, please warn me if I did something wrong.(I am new here.) import pygame, sys, random

screen_width = 600 screen_height = 600 gridsize = 20 grid_width = screen_width / gridsize grid_height = screen_height / gridsize

light_green = (0,170,140) dark_green = (0,140,120) food_color = (250,200,0) snake_color = (34,34,34)

up = (0,-1) down = (0,+1) right = (1,0) left = (-1,0)

def drawGrid(surface): for y in range (0,int(grid_height)): for x in range (0,int(grid_width)): if (x + y) %2 == 0: light = pygame.Rect((x gridsize , y gridsize),(gridsize,gridsize)) pygame. draw.rect(surface,light_green,light) else: dark = pygame.Rect((xgridsize,ygridsize),(gridsize,gridsize)) pygame.draw.rect(surface,dark_green,dark)

def main(): pygame.init() screen = pygame.display.set_mode((screen_height,screen_width))

font = pygame.font.SysFont("Segeo UI Black",20) surface = pygame.Surface(screen.get_size()) surface = surface.convert()

while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit()

drawGrid(surface)
screen.blit(surface,(0,0))
pygame.display.update()

Configuration

No response

Command used

pylint a.py

Pylint output

File "C:\Users\EFE\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\EFE\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "c:\Users\EFE\.vscode\extensions\ms-python.python-2022.18.2\pythonFiles\lib\python\debugpy\__main__.py", line 39, in <module>
    cli.main()
  File "c:\Users\EFE\.vscode\extensions\ms-python.python-2022.18.2\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 430, in main
    run()
  File "c:\Users\EFE\.vscode\extensions\ms-python.python-2022.18.2\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "c:\Users\EFE\.vscode\extensions\ms-python.python-2022.18.2\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 320, in run_path
    code, fname = _get_code_from_file(run_name, path_name)
  File "c:\Users\EFE\.vscode\extensions\ms-python.python-2022.18.2\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 294, in _get_code_from_file
    code = compile(f.read(), fname, 'exec')
  File "c:\Users\EFE\Desktop\SnakeGame.py", line 27
    else:
    ^^^^

Expected behavior

dont know

Pylint version

pylint=2.15.5.

OS / Environment

windows 10

Additional dependencies

No response

clavedeluna commented 1 year ago

Thanks for the report. Could you please remove the image and include the code as text? That's easy to parse for us. Also, please provide the entire pylint trace error. We will try to reproduce.

Pierre-Sassoulas commented 1 year ago

This indentation of pygame.draw is wrong you need to move it 4 spaces to the right before the else. But this is something you should search on the web, pylint is just the messenger, this is not the right place to ask your question about python.