Skip to content

Commit

Permalink
refs #26: Attempt to disable this false positive
Browse files Browse the repository at this point in the history
  • Loading branch information
geckon committed Dec 1, 2018
1 parent 67685eb commit f628a9e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions twnsol/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import random

import pygame
from pygame.constants import K_1, K_2, K_3, K_4, KEYDOWN, QUIT

from twnsol.config import CONF
from twnsol.constants import CONST
Expand Down Expand Up @@ -236,7 +235,7 @@ def game_over(self):
# Wait for exit
while True:
event = pygame.event.wait()
if event.type == QUIT:
if event.type == pygame.QUIT: # pylint: disable=no-member
exit()

def check_game_over(self):
Expand Down Expand Up @@ -339,16 +338,16 @@ def process_key(self, event):
Add the upcoming card to a respective column if the player made
a valid turn. In such case, return True, False otherwise.
"""
if event.key == K_1:
if event.key == pygame.K_1:
logging.debug('Key 1 pressed.')
return self.add_next_to_col(0)
if event.key == K_2:
if event.key == pygame.K_2:
logging.debug('Key 2 pressed.')
return self.add_next_to_col(1)
if event.key == K_3:
if event.key == pygame.K_3:
logging.debug('Key 3 pressed.')
return self.add_next_to_col(2)
if event.key == K_4:
if event.key == pygame.K_4:
logging.debug('Key 4 pressed.')
return self.add_next_to_col(3)

Expand All @@ -364,10 +363,10 @@ def loop(self):
while True:
self.draw_board()
event = pygame.event.wait()
if event.type == QUIT:
if event.type == pygame.QUIT:
exit()

if event.type == KEYDOWN:
if event.type == pygame.KEYDOWN:
self.process_key(event)
else:
logging.debug('Unsupported event: %s', event)
Expand All @@ -377,4 +376,6 @@ def loop(self):

def get_random_card():
"""Generate a random card value."""
return 2 ** random.randint(1, 6)
# the nosec comment is for bandit - see issue #25
# TL;DR pseudo-random generator is unsafe for crypto use but OK here
return 2 ** random.randint(1, 6) # nosec

0 comments on commit f628a9e

Please sign in to comment.