diff --git a/diner.py b/diner.py index fbd2f07081fa4dd8172badfba479d7cb6c444a2c..c0ad745f0d539da4ec00b956cd2a8734c160aa0c 100644 --- a/diner.py +++ b/diner.py @@ -8,7 +8,7 @@ from sqlalchemy.orm import sessionmaker, relationship # class that we can use for objects that we want SQLAlchemy to persist in a # database. We then store that class in variable named Persisted; effectively, # we make a new class called Persisted. -Persisted = declarative_base() +Persisted = declarative_base() # pylint: disable=invalid-name class Menu(Persisted): @@ -42,8 +42,7 @@ class OrderItem(Persisted): class DinerDatabase(object): @staticmethod def construct_mysql_url(authority, port, database, username, password): - return 'mysql+mysqlconnector://{username}:{password}@{authority}:{port}/{database}' \ - .format(authority=authority, port=port, database=database, username=username, password=password) + return f'mysql+mysqlconnector://{username}:{password}@{authority}:{port}/{database}' @staticmethod def construct_in_memory_url(): @@ -51,7 +50,7 @@ class DinerDatabase(object): def __init__(self, url): self.engine = create_engine(url) # an engine is like an endpoint, something to connect to - self.Session = sessionmaker() # create a class for connections to that endpoint + self.Session = sessionmaker() # create a class for connections to that endpoint / pylint: disable=invalid-name self.Session.configure(bind=self.engine) # associate the class with the endpoint def ensure_tables_exist(self): diff --git a/diner_installer.py b/diner_installer.py index 3846cf0ede278df54e2871998baad6f561dda15b..470467136f61cde07d4d62d628b8ce3f752b6073 100644 --- a/diner_installer.py +++ b/diner_installer.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8; -*- - from sys import stderr from sqlalchemy.exc import SQLAlchemyError @@ -34,7 +32,7 @@ def main(): print('Records created.') except SQLAlchemyError as exception: print('Database setup failed!', file=stderr) - print('Cause: {exception}'.format(exception=exception), file=stderr) + print(f'Cause: {exception}', file=stderr) exit(1)