A
acceptance test 287
adapters 383
advanced coroutines 266
advanced decorators 165
docstrings, replacing 17
anti-patterns, for inheritance 100, 101, 102, 103
Application Programming Interface (API) 74
arguments
copying, to functions 107, 108
in functions 107
in methods 107
passing, to decorators 165, 166
variable number 109, 110, 111, 112, 113
artifacts
versions 376
assertions
asymptotic notation 56
asynchronous context managers 276, 277
asynchronous generators 280, 281
asynchronous iteration 278, 279, 280
asynchronous programming 273, 275
automatic checks
B
behavioral patterns 344
chain of responsibility 345, 347, 348
template method 348
black
reference link 24
boundary values 323
built-in types
C
chain of responsibility 345, 347, 348
class decorators 161, 162, 163, 164, 190, 191
classes
creating, with compact syntax 49, 50, 51, 52
clean architecture 364
Coala
reference link 23
code
generic validations 22
structuring 122
tracing 178
code coverage 306
code documentation 9
code formatting 6
cohesion 91
compact function signatures 118, 119
component testing 287
composite pattern 339
composition 189
comprehension expressions 40, 42
methods 35
Continuous Integration (CI) 19
contract 74
invariants 75
postconditions 75
preconditions 75
side effects 75
delegating into 268
coupling 91
coverage
reference link 306
creational patterns 330
factories 330
singleton 331
curio
reference link 69
D
data
receiving, from sub-generator 271, 272, 273
sending, to sub-generator 271, 272, 273
data descriptor 212, 214, 215, 216
decorator pattern 340, 341, 342
decorators
advanced decorators 165
arguments, passing to 165, 166
benefits 176
clean code 189
common mistakes, avoiding 178
data, preserving for original wrapped object 179, 180, 181
descriptors, implementing in 237
extended syntax 175
for classes 160, 161, 162, 163, 164
good decorators, analysis 195, 196
incorrect handling, of side effects 182, 183, 184
requiring, with side effects 184, 185
separation of concerns 193, 195
side effects 181
types 165
with default values 169, 170, 171, 172
with nested functions 166, 168
defensive programming 78
Dependabot
URL 373
dependencies
rigid dependencies 150
dependency injection 151, 152, 153, 154
dependency inversion principle (DIP) 149
Dependency Inversion Principle (DIP) 367
descriptor 333
descriptor protocol, methods 203
get 204
descriptors 200, 201, 202, 203
analysis 230
application 217
attempt, without descriptors 217, 218, 219
code, reusing 225
considerations 225
data descriptors 214, 215, 216
dictionary, accessing of object 223
idiomatic implementation 219, 220, 221
implementing 222
implementing, in decorators 237
interface 237
issue of shared state 222, 223
non-data descriptors 212, 213, 214
object-oriented design 238
type annotations, applying on 238
weak references, using 224
working 217
descriptors, Python
built-in decorators, for methods 234, 235
using 230
Design by Contract (DbC) 178
design patterns 358
as theory 359
behavioral patterns 344
considerations, in Python 328, 329
creational patterns 330
names, in models 360
structural patterns 337
design principles 286
documentation 9
Don't Repeat Yourself (DRY) 92
Don't Repeat Yourself (DRY) principle 192
with decorators 193
Don't Repeat Yourself (DRY) principle 305
duck typing 145
dynamic attributes
E
edge cases 324
empty except blocks
equivalence class 323
events system
refactoring, for extensibility 133, 135
exceptions
handling, at right level of abstraction 81, 83, 84, 85
F
facade pattern 343
factory pattern 330
flake8 23
for Easier to Ask Forgiveness than Permission (EAFP) 98
function arguments
and coupling 117
working 107
functions
arguments, copying to 107, 108
number of arguments 117
function signatures
functools.partial
reference link 227
G
generator interface, methods 260
send(value) 263, 264, 265, 266
throw(ex_type[, ex_value[, ex_traceback]]) 261, 262, 263
generators
creating 242
generic validations
God objects 126
Graphene
URL 61
GraphQL
URL 61
H
hexagonal architecture (HEX) 368
hint 13
http.server package
reference link 100
I
idioms
incompatible signatures
detecting, with pylint 140
incorrect method signatures
inheritance 189
anti-patterns 100, 101, 102, 103
in Python 99
integration test 287
intention revealing 390
interface 145
interface segregation principle (ISP) 144, 145, 146, 147, 148, 149
IPython
URL 11
iterable 256
iterable objects 52
iteration
iterator 256
iterator pattern
in Python 255
iterators
code, simplifying 252
itertools module 251, 252, 253
K
keyword-only arguments 115, 116
KIS (Keep It Simple) 95, 96, 97
L
limit values 323
Liskov's substitution principle (LSP) 137, 138, 144
Look Before You Leap (LBYL) 98
LSP issues, detecting with tools 138
mypy, used for detecting incorrect method signatures 138, 139
pylint, used for detecting incompatible signatures 140
LSP violations
subtle cases 141, 142, 143, 144
M
magic asynchronous methods 275
maintainability perils
maintainability perils
examples 130
Method Resolution Order (MRO) 104, 105
microservices architecture 366
mixin 106
mocking 287
mock objects 309
using 310
monolithic applications 367
monostate pattern 331
mutable default arguments 64, 65
mutants 320
mutation testing 320, 321, 322
mypy
used, for detecting incorrect method signatures 138, 139
N
non-data descriptor 212
non-data descriptors 212, 213, 214
O
object-oriented design
of descriptors 238
Object-Relational Mapper (ORM) 368
Object Relational Mapper SQLAlchemy (ORM SQLAlchemy) 349
objects
calling, from applications 382, 383
Once and Only Once (OAOO) 92
open/closed principle (OCP) 129, 130, 137
events system, extending 135, 136, 137
events system, refactoring for extensibility 133, 135
maintainability perils, examples 130, 131
maintainability perils, examples for not following 132
Open/Closed Principle (OCP) 229
original exception
P
parameterized tests 299
parameters
validating 178
patching 310
patterns
influence, over design 358
PEP-8
quality traits, for projects 8
reference link 6
pinject
reference link 153
Portable Operating System Interface (POSIX) 344
positional-only parameters 114, 115
preconditions 76
property-based testing 320
pylint
used, for detecting incompatible signatures 140
pylint command 22
PyPi
reference link 369
pytest 301
fixtures 304
reference link 294
pytest-cov package 307
Python
descriptors, using 230
design pattern considerations 328, 329
Python, caveats 64
built-in types, extending 66, 67, 68
mutable default arguments 64, 65
Python, features
attributes 43
methods for objects, types 43
Python,features
underscores 46
Pythonic contracts 77
pytype
Q
query 349
R
read the docs
URL 13
red-green-refactor 325
refactoring 315
repeated iterations 253
ripple effect 90
S
separation of concerns 90, 91, 364, 365
Separation of Concerns (SoC) 378
Sequence interface implementation, from collections.abc module
reference link 33
sequence objects
sequences
service-level agreements (SLAs) 366
service-level objectives (SLOs) 366
analysis 388
dependency flow 388
limitations 389
testability 389
shared state 331, 332, 333, 334
single responsibility principle (SRP) 126, 195
class, with many responsibilities 126, 127, 128
responsibilities, distributing 128, 129
singleton pattern 331
software
software components 368
use case 378
Software Configuration Management (SCM) 372
software design
good practices 120
specialization 100
state pattern 350, 351, 353, 354, 355
structural patterns 337
composite 339
facade 343
subclass 99
sub-generator
data, receiving from 271, 272, 273
data, sending to 271, 272, 273
superclass 99
T
template method 348
testability 289
test coverage
setting up 307
test double 310
test-driven design 289
Test-Driven Design (TDD) 324
test-driven development 325
boundaries, defining 293
property-based testing 320
themes 323
tools 293
The Cathedral and the Bazaar (CatB) 288
tooling 19
tracebacks, of exceptions 85
tracing 178
trio
type annotations
applying, on descriptors 238
type consistency
U
isolation 286
performance 286
repeatability 286
self-validating 286
unittest
reference link 294
unit testing 286
agile software development 288, 289
software design 289, 290, 291, 292
unittest module 295, 296, 297, 298
parameterized tests 299, 300, 301
adapters 383
code 379
uvloop
reference link 275
V
value
capturing, returned by sub-generator 270, 271
values
returning, in coroutines 266, 268
W
wrapped object 159
wrapper 337
Y
YAGNI (You Ain't Gonna Need It) 94, 95
yapf
reference link 25
18.118.193.232