Skip to content

Commit d450773

Browse files
committed
Fixed some RealPython PR code style issues
1 parent 97d0560 commit d450773

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

flask-connexion-rest-part-3/build_database.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
"fname": "Kent",
1919
"lname": "Brockman",
2020
"notes": [
21-
("I'm going to make really profound observations", "2019-01-07 22:17:54"),
22-
("Maybe they'll be more obvious than I thought", "2019-02-06 22:17:54"),
21+
("I'm going to make really profound observations",
22+
"2019-01-07 22:17:54"),
23+
("Maybe they'll be more obvious than I thought",
24+
"2019-02-06 22:17:54"),
2325
]
2426
},
2527
{
@@ -46,7 +48,10 @@
4648
# Add the notes for the person
4749
for note in person.get("notes"):
4850
content, timestamp = note
49-
p.notes.append(Note(content=content, timestamp=datetime.strptime(timestamp, "%Y-%m-%d %H:%M:%S")))
51+
p.notes.append(Note(
52+
content=content,
53+
timestamp=datetime.strptime(timestamp, "%Y-%m-%d %H:%M:%S"))
54+
)
5055
db.session.add(p)
5156

5257
db.session.commit()

flask-connexion-rest-part-3/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from marshmallow import fields
44

55

6-
76
class Person(db.Model):
87
__tablename__ = 'person'
98
person_id = db.Column(db.Integer, primary_key=True)

flask-connexion-rest-part-3/notes.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def read_all():
2626

2727
def read_one(person_id, note_id):
2828
"""
29-
This function responds to a request for /api/people/{person_id}/notes/{note_id}
29+
This function responds to a request for
30+
/api/people/{person_id}/notes/{note_id}
3031
with one matching note for the associated person
3132
3233
:param person_id: Id of person the note is related to
@@ -72,9 +73,6 @@ def create(person_id, note):
7273
"Person not found for Id: {person_id}".format(person_id=person_id),
7374
)
7475

75-
# Get the note content from the JSON body
76-
content = note.get("content")
77-
7876
# Create a note schema instance
7977
schema = NoteSchema()
8078
new_note = schema.load(note, session=db.session).data
@@ -99,8 +97,6 @@ def update(person_id, note_id, note):
9997
:param content: The JSON containing the note data
10098
:return: 200 on success
10199
"""
102-
content = note.get("content")
103-
104100
update_note = Note.query \
105101
.filter(Person.person_id == person_id) \
106102
.filter(Note.note_id == note_id) \

flask-connexion-rest-part-3/people.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def read_one(person_id):
3838
.outerjoin(Note) \
3939
.one_or_none()
4040

41-
# Did we find a person?
41+
# Did we find a person?
4242
if person is not None:
4343

4444
# Serialize the data for the response

0 commit comments

Comments
 (0)