Applying black formatting

- Fixing flake8 configuration to agree with black
- Adding black validation check to github actions
This commit is contained in:
Jacob Alexander
2021-10-01 11:00:22 -07:00
parent 5dade41aeb
commit 6e7fffd7de
51 changed files with 2536 additions and 1837 deletions

View File

@@ -6,35 +6,38 @@ try:
except:
profile = lambda func: func
this_dir = os.path.dirname(__file__)
addressbook = capnp.load(os.path.join(this_dir, 'addressbook.capnp'))
addressbook = capnp.load(os.path.join(this_dir, "addressbook.capnp"))
print = lambda *x: x
@profile
def writeAddressBook():
addressBook = addressbook.AddressBook.new_message()
people = addressBook.init('people', 2)
people = addressBook.init("people", 2)
alice = people[0]
alice.id = 123
alice.name = 'Alice'
alice.email = 'alice@example.com'
alicePhones = alice.init('phones', 1)
alice.name = "Alice"
alice.email = "alice@example.com"
alicePhones = alice.init("phones", 1)
alicePhones[0].number = "555-1212"
alicePhones[0].type = 'mobile'
alicePhones[0].type = "mobile"
bob = people[1]
bob.id = 456
bob.name = 'Bob'
bob.email = 'bob@example.com'
bobPhones = bob.init('phones', 2)
bob.name = "Bob"
bob.email = "bob@example.com"
bobPhones = bob.init("phones", 2)
bobPhones[0].number = "555-4567"
bobPhones[0].type = 'home'
bobPhones[0].type = "home"
bobPhones[1].number = "555-7654"
bobPhones[1].type = 'work'
bobPhones[1].type = "work"
msg_bytes = addressBook.to_bytes()
return msg_bytes
@profile
def printAddressBook(msg_bytes):
addressBook = addressbook.AddressBook.from_bytes(msg_bytes)
@@ -44,31 +47,34 @@ def printAddressBook(msg_bytes):
for phone in person.phones:
phone.type, phone.number
@profile
def writeAddressBookDict():
addressBook = addressbook.AddressBook.new_message()
people = addressBook.init('people', 2)
people = addressBook.init("people", 2)
alice = people[0]
alice.id = 123
alice.name = 'Alice'
alice.email = 'alice@example.com'
alicePhones = alice.init('phones', 1)
alice.name = "Alice"
alice.email = "alice@example.com"
alicePhones = alice.init("phones", 1)
alicePhones[0].number = "555-1212"
alicePhones[0].type = 'mobile'
alicePhones[0].type = "mobile"
bob = people[1]
bob.id = 456
bob.name = 'Bob'
bob.email = 'bob@example.com'
bobPhones = bob.init('phones', 2)
bob.name = "Bob"
bob.email = "bob@example.com"
bobPhones = bob.init("phones", 2)
bobPhones[0].number = "555-4567"
bobPhones[0].type = 'home'
bobPhones[0].type = "home"
bobPhones[1].number = "555-7654"
bobPhones[1].type = 'work'
bobPhones[1].type = "work"
msg = addressBook.to_dict()
return msg
@profile
def printAddressBookDict(msg):
addressBook = addressbook.AddressBook.new_message(**msg)
@@ -79,7 +85,7 @@ def printAddressBookDict(msg):
phone.type, phone.number
if __name__ == '__main__':
if __name__ == "__main__":
# for i in range(10000):
# msg_bytes = writeAddressBook()
@@ -88,4 +94,3 @@ if __name__ == '__main__':
msg = writeAddressBookDict()
printAddressBookDict(msg)