Run pre-commit on all files

This commit is contained in:
Charles-Axel Dein
2020-07-21 09:37:15 +02:00
parent 4af5a19d79
commit ec0f449ede
22 changed files with 125 additions and 36 deletions

View File

@@ -1,7 +1,6 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# Table of Contents
## Table of Contents
- [Antipatterns](#antipatterns)

View File

@@ -1,7 +1,6 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# Table of Contents
## Table of Contents
- [Antipatterns](#antipatterns)
- [Strict email validation](#strict-email-validation)

View File

@@ -1,7 +1,6 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# Table of Contents
## Table of Contents
- [Database anti-patterns](#database-anti-patterns)
- [Using `VARCHAR` instead of `TEXT` (PostgreSQL)](#using-varchar-instead-of-text-postgresql)

View File

@@ -1,7 +1,6 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# Table of Contents
## Table of Contents
- [Error handling anti-patterns](#error-handling-anti-patterns)
- [Hiding exceptions](#hiding-exceptions)

View File

@@ -1,7 +1,6 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# Table of Contents
## Table of Contents
- [MVCS Antipatterns](#mvcs-antipatterns)
- [Creating entities for association tables](#creating-entities-for-association-tables)

View File

@@ -1,7 +1,6 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# Table of Contents
## Table of Contents
- [Python Antipatterns](#python-antipatterns)
- [Redundant type checking](#redundant-type-checking)

View File

@@ -1,19 +1,21 @@
from collections import namedtuple
Bread = namedtuple('Bread', 'color')
Bread = namedtuple("Bread", "color")
class ToastException(Exception):
pass
def toast(bread):
try:
put_in_toaster(bread)
except:
raise ToastException('Could not toast bread')
raise ToastException("Could not toast bread")
def put_in_toaster(bread):
brad.color = 'light_brown' # Note the typo
brad.color = "light_brown" # Note the typo
toast(Bread('yellow'))
toast(Bread("yellow"))

View File

@@ -1,20 +1,22 @@
from collections import namedtuple
Bread = namedtuple('Bread', 'color')
Bread = namedtuple("Bread", "color")
class ToastException(Exception):
pass
def toast(bread):
try:
put_in_toaster(bread)
except:
print 'Got exception while trying to toast'
print("Got exception while trying to toast")
raise
def put_in_toaster(bread):
brad.color = 'light_brown' # Note the typo
brad.color = "light_brown" # Note the typo
toast(Bread('yellow'))
toast(Bread("yellow"))

View File

@@ -1,7 +1,6 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# Table of Contents
## Table of Contents
- [Not paging a database query](#not-paging-a-database-query)
- [Returning whole objects where primary key would suffice](#returning-whole-objects-where-primary-key-would-suffice)

View File

@@ -1,7 +1,6 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# Table of Contents
## Table of Contents
- [SQLAlchemy Anti-Patterns](#sqlalchemy-anti-patterns)
- [Abusing lazily loaded relationships](#abusing-lazily-loaded-relationships)

View File

@@ -4,13 +4,13 @@ from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('sqlite:///:memory:', echo=True)
engine = create_engine("sqlite:///:memory:", echo=True)
Session = sessionmaker(bind=engine)
Base = declarative_base()
class Toaster(Base):
__tablename__ = 'toasters'
__tablename__ = "toasters"
id = Column(Integer, primary_key=True)
name = Column(String)

View File

@@ -1,7 +1,6 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# Table of Contents
## Table of Contents
- [Test antipatterns](#test-antipatterns)
- [Testing implementation](#testing-implementation)