fixing pylint violations
This commit is contained in:
		
							parent
							
								
									19a4dde84f
								
							
						
					
					
						commit
						afbb2ba37f
					
				
					 6 changed files with 34 additions and 22 deletions
				
			
		| 
						 | 
					@ -4,6 +4,7 @@ from brewing import cooking
 | 
				
			||||||
from brewing import inspection
 | 
					from brewing import inspection
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def make_example_potion(student_name="ASPP student"):
 | 
					def make_example_potion(student_name="ASPP student"):
 | 
				
			||||||
 | 
					    """Make and return an example potion."""
 | 
				
			||||||
    my_potion = potion_class.Potion(student_name=student_name)
 | 
					    my_potion = potion_class.Potion(student_name=student_name)
 | 
				
			||||||
    # Set up your old kettle and light an eternal flame underneath it.
 | 
					    # Set up your old kettle and light an eternal flame underneath it.
 | 
				
			||||||
    my_potion.setup(container=containers.OLD_KETTLE)
 | 
					    my_potion.setup(container=containers.OLD_KETTLE)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
# containers
 | 
					"""Constants: containers for poton-making.
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
PEWTER_CAULDRON = 'pewter_cauldron'
 | 
					PEWTER_CAULDRON = 'pewter_cauldron'
 | 
				
			||||||
COPPER_CAULDRON = 'copper_cauldron'
 | 
					COPPER_CAULDRON = 'copper_cauldron'
 | 
				
			||||||
MARTINI_GLASS = 'martini_glass'
 | 
					MARTINI_GLASS = 'martini_glass'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,5 @@
 | 
				
			||||||
 | 
					"""Functions and constants for cooking.
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
# heat sources
 | 
					# heat sources
 | 
				
			||||||
FIRE = 'fire'
 | 
					FIRE = 'fire'
 | 
				
			||||||
ETERNAL_FLAME = 'eternal_flame'
 | 
					ETERNAL_FLAME = 'eternal_flame'
 | 
				
			||||||
| 
						 | 
					@ -44,7 +46,8 @@ def simmer(potion, duration):
 | 
				
			||||||
    if duration < 2:
 | 
					    if duration < 2:
 | 
				
			||||||
        print('Are you sure you are cooking the potion enough? Your ingredients look a bit raw...')
 | 
					        print('Are you sure you are cooking the potion enough? Your ingredients look a bit raw...')
 | 
				
			||||||
    elif duration > 5:
 | 
					    elif duration > 5:
 | 
				
			||||||
        print('Oops, you have fallen asleep at your desk! Are you sure you want to simmer this long?')
 | 
					        print('Oops, you have fallen asleep at your desk! '
 | 
				
			||||||
 | 
					              + 'Are you sure you want to simmer this long?')
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        potion.cooked = True
 | 
					        potion.cooked = True
 | 
				
			||||||
    return
 | 
					    return
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
# ingredients
 | 
					"""Constants: ingredients for the potions.
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
SNAKE_SKIN = 'snake_skin'
 | 
					SNAKE_SKIN = 'snake_skin'
 | 
				
			||||||
FISH_EYES = 'fish_eyes'
 | 
					FISH_EYES = 'fish_eyes'
 | 
				
			||||||
UNICORN_HAIR = 'unicorn_hair'
 | 
					UNICORN_HAIR = 'unicorn_hair'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,10 @@
 | 
				
			||||||
 | 
					# pylint: disable=line-too-long
 | 
				
			||||||
 | 
					"""Functionality to inspect potions.
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
import time
 | 
					import time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def inspection_by_Snape(potion, target_potion='python_expert'):
 | 
					def inspection_by_Snape(potion, target_potion='python_expert'):  # pylint: disable=invalid-name
 | 
				
			||||||
    """Checks if potion was brewed correctly.
 | 
					    """Checks if potion was brewed correctly.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Prints narration of inspection process - read to see if potion passed inspection.
 | 
					    Prints narration of inspection process - read to see if potion passed inspection.
 | 
				
			||||||
| 
						 | 
					@ -18,8 +21,8 @@ def inspection_by_Snape(potion, target_potion='python_expert'):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    print('-------------------------------')
 | 
					    print('-------------------------------')
 | 
				
			||||||
    if not potion:
 | 
					    if not potion:
 | 
				
			||||||
        print(f'"There is no potion I can inspect!"')
 | 
					        print('"There is no potion I can inspect!"')
 | 
				
			||||||
        print(f'    (Tip: are you actually returning a proper potion and passing it to Snape?)')
 | 
					        print('    (Tip: are you actually returning a proper potion and passing it to Snape?)')
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    print(f'A sour looking Snape walks towards you to inspect your {target_potion} potion.')
 | 
					    print(f'A sour looking Snape walks towards you to inspect your {target_potion} potion.')
 | 
				
			||||||
| 
						 | 
					@ -35,12 +38,12 @@ def inspection_by_Snape(potion, target_potion='python_expert'):
 | 
				
			||||||
        expected_heat_source = 'eternal_flame'
 | 
					        expected_heat_source = 'eternal_flame'
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        print(f'"What is this, {potion.student_name}? This is not the name of an existing potion, check your spelling!"')
 | 
					        print(f'"What is this, {potion.student_name}? This is not the name of an existing potion, check your spelling!"')
 | 
				
			||||||
        print(f'    (Target potion was not recognised, please check your spelling.)')
 | 
					        print('    (Target potion was not recognised, please check your spelling.)')
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # check that correct setup was used
 | 
					    # check that correct setup was used
 | 
				
			||||||
    if potion.container == expected_container and potion.heat_source == expected_heat_source:
 | 
					    if potion.container == expected_container and potion.heat_source == expected_heat_source:
 | 
				
			||||||
        print(f'You have used the correct setup, Snape cannot complain - he looks even more sour.')
 | 
					        print('You have used the correct setup, Snape cannot complain - he looks even more sour.')
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        print(f'Snape smirks and remarks "You have used the wrong cauldron or heat, {potion.student_name}!" \n'
 | 
					        print(f'Snape smirks and remarks "You have used the wrong cauldron or heat, {potion.student_name}!" \n'
 | 
				
			||||||
              f'With a flick of his wand he vanishes the potion. \n'
 | 
					              f'With a flick of his wand he vanishes the potion. \n'
 | 
				
			||||||
| 
						 | 
					@ -60,12 +63,12 @@ def inspection_by_Snape(potion, target_potion='python_expert'):
 | 
				
			||||||
        expected_simmer_duration = 5
 | 
					        expected_simmer_duration = 5
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        print(f'"What is this, {potion.student_name}? This is not the name of an existing potion, check your spelling!"')
 | 
					        print(f'"What is this, {potion.student_name}? This is not the name of an existing potion, check your spelling!"')
 | 
				
			||||||
        print(f'    (Target potion was not recognised, please check your spelling.)')
 | 
					        print('    (Target potion was not recognised, please check your spelling.)')
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # check if all ingredients are there
 | 
					    # check if all ingredients are there
 | 
				
			||||||
    if sorted(potion.ingredients) == expected_ingredients:
 | 
					    if sorted(potion.ingredients) == expected_ingredients:
 | 
				
			||||||
        print(f'You have used the correct ingredients, Snape cannot complain - his face darkens.')
 | 
					        print('You have used the correct ingredients, Snape cannot complain - his face darkens.')
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        print(f'Snape smirks and remarks "You have used the wrong ingredients, {potion.student_name}!" \n'
 | 
					        print(f'Snape smirks and remarks "You have used the wrong ingredients, {potion.student_name}!" \n'
 | 
				
			||||||
              f'With a flick of his wand he vanishes the potion. \n'
 | 
					              f'With a flick of his wand he vanishes the potion. \n'
 | 
				
			||||||
| 
						 | 
					@ -76,12 +79,12 @@ def inspection_by_Snape(potion, target_potion='python_expert'):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # check that potion is cooked
 | 
					    # check that potion is cooked
 | 
				
			||||||
    if potion.cooked == expected_cooked and potion.simmer_duration == expected_simmer_duration:
 | 
					    if potion.cooked == expected_cooked and potion.simmer_duration == expected_simmer_duration:
 | 
				
			||||||
        print(f'The potion is cooked properly, Snape cannot complain - he is looking annyoyed now.')
 | 
					        print('The potion is cooked properly, Snape cannot complain - he is looking annyoyed now.')
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        if potion.simmer_duration < expected_simmer_duration:
 | 
					        if potion.simmer_duration < expected_simmer_duration:
 | 
				
			||||||
            print(f'Snape smirks and remarks "Your potion is undercooked!" \n')
 | 
					            print('Snape smirks and remarks "Your potion is undercooked!" \n')
 | 
				
			||||||
        elif potion.simmer_duration > expected_simmer_duration:
 | 
					        elif potion.simmer_duration > expected_simmer_duration:
 | 
				
			||||||
            print(f'Snape smirks and remarks "Your potion is overcooked!" \n')
 | 
					            print('Snape smirks and remarks "Your potion is overcooked!" \n')
 | 
				
			||||||
        print(f'With a flick of his wand he vanishes the potion. \n'
 | 
					        print(f'With a flick of his wand he vanishes the potion. \n'
 | 
				
			||||||
              f'"I am taking 10 points from Hufflepuff, {potion.student_name}. Start again!"')
 | 
					              f'"I am taking 10 points from Hufflepuff, {potion.student_name}. Start again!"')
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
| 
						 | 
					@ -91,13 +94,13 @@ def inspection_by_Snape(potion, target_potion='python_expert'):
 | 
				
			||||||
    print(f'Snape mutters "You got away this time, {potion.student_name}!", since there is nothing wrong with '
 | 
					    print(f'Snape mutters "You got away this time, {potion.student_name}!", since there is nothing wrong with '
 | 
				
			||||||
          f'your {target_potion} potion.')
 | 
					          f'your {target_potion} potion.')
 | 
				
			||||||
    print_delay_dots()
 | 
					    print_delay_dots()
 | 
				
			||||||
    print(f'You pack your bags and leave as fast as you can to have a butterbeer at the lake!')
 | 
					    print('You pack your bags and leave as fast as you can to have a butterbeer at the lake!')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return
 | 
					    return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
def print_delay_dots(dur=0.5, number=2):
 | 
					def print_delay_dots(dur=0.5, number=2):
 | 
				
			||||||
    for i in range(number):
 | 
					    """Print dots to screen during delay."""
 | 
				
			||||||
 | 
					    for _ in range(number):
 | 
				
			||||||
        time.sleep(dur)
 | 
					        time.sleep(dur)
 | 
				
			||||||
        print('.')
 | 
					        print('.')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,10 @@
 | 
				
			||||||
 | 
					"""The potion class."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Potion:
 | 
					class Potion:
 | 
				
			||||||
 | 
					    """A class for brewing potions."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, student_name):
 | 
					    def __init__(self, student_name):
 | 
				
			||||||
        """This is a class for brewing potions."""
 | 
					 | 
				
			||||||
        self.colour = 'there-is-no-potion-so-the-potion-has-no-color'
 | 
					        self.colour = 'there-is-no-potion-so-the-potion-has-no-color'
 | 
				
			||||||
        self.cooked = False
 | 
					        self.cooked = False
 | 
				
			||||||
        self.container = None
 | 
					        self.container = None
 | 
				
			||||||
| 
						 | 
					@ -22,10 +25,10 @@ class Potion:
 | 
				
			||||||
        heat_source : str, optional
 | 
					        heat_source : str, optional
 | 
				
			||||||
            The name of the heat source used to cook the potions
 | 
					            The name of the heat source used to cook the potions
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        if container == None:
 | 
					        if container is None:
 | 
				
			||||||
            print(f'You have not specified a container - where do you think you will brew your potion?')
 | 
					            print('You have not specified a container - where do you think you will brew your potion?')
 | 
				
			||||||
        if heat_source == None:
 | 
					        if heat_source is None:
 | 
				
			||||||
            print(f'You have not specified a heat source - how will you cook the potion?')
 | 
					            print('You have not specified a heat source - how will you cook the potion?')
 | 
				
			||||||
        self.container = container
 | 
					        self.container = container
 | 
				
			||||||
        self.heat_source = heat_source
 | 
					        self.heat_source = heat_source
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,7 +43,7 @@ class Potion:
 | 
				
			||||||
            A list of ingredients (str) to add to the potion.
 | 
					            A list of ingredients (str) to add to the potion.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        if ingredients is None:
 | 
					        if ingredients is None:
 | 
				
			||||||
            print(f'You have added no ingredients - have you spilt them on the floor again?')
 | 
					            print('You have added no ingredients - have you spilt them on the floor again?')
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            self.ingredients = ingredients
 | 
					            self.ingredients = ingredients
 | 
				
			||||||
            self.colour = "transparent"
 | 
					            self.colour = "transparent"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue