Skip to content

Commit 562c4af

Browse files
author
Kareem Zidane
authored
Merge pull request #64 from cs50/style
style, commenting improvements
2 parents 4cfc648 + 476650d commit 562c4af

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
package_dir={"": "src"},
1717
packages=["cs50"],
1818
url="https://github.com/cs50/python-cs50",
19-
version="2.4.4"
19+
version="2.4.5"
2020
)

src/cs50/sql.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,18 @@ def _parse(self, e):
8787
return str(e)
8888

8989
def execute(self, text, **params):
90-
"""
91-
Execute a SQL statement.
92-
"""
90+
"""Execute a SQL statement."""
91+
9392
class UserDefinedType(sqlalchemy.TypeDecorator):
94-
"""
95-
Add support for expandable values, a la https://bitbucket.org/zzzeek/sqlalchemy/issues/3953/expanding-parameter.
96-
"""
93+
"""Add support for expandable values, a la https://github.com/sqlalchemy/sqlalchemy/issues/3953."""
9794

95+
# Required class-level attribute
96+
# https://docs.sqlalchemy.org/en/latest/core/custom_types.html#sqlalchemy.types.TypeDecorator
9897
impl = sqlalchemy.types.UserDefinedType
9998

10099
def process_literal_param(self, value, dialect):
101100
"""Receive a literal parameter value to be rendered inline within a statement."""
101+
102102
def process(value):
103103
"""Render a literal value, escaping as needed."""
104104

@@ -147,8 +147,7 @@ def process(value):
147147
else:
148148
return process(value)
149149

150-
# Allow only one statement at a time
151-
# SQLite does not support executing many statements
150+
# Allow only one statement at a time, since SQLite doesn't support multiple
152151
# https://docs.python.org/3/library/sqlite3.html#sqlite3.Cursor.execute
153152
if len(sqlparse.split(text)) > 1:
154153
raise RuntimeError("too many statements at once")
@@ -234,10 +233,10 @@ def process(value):
234233
def _connect(dbapi_connection, connection_record):
235234
"""Enables foreign key support."""
236235

237-
# Ensure backend is sqlite
236+
# If back end is sqlite
238237
if type(dbapi_connection) is sqlite3.Connection:
239-
cursor = dbapi_connection.cursor()
240238

241239
# Respect foreign key constraints by default
240+
cursor = dbapi_connection.cursor()
242241
cursor.execute("PRAGMA foreign_keys=ON")
243242
cursor.close()

0 commit comments

Comments
 (0)