Run pre-commit on all files
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user