Index

A

abstractions 367, 368

acceptance test 287

adapter pattern 337, 338, 339

adapters 383

advanced coroutines 266

advanced decorators 165

annotations 13, 14, 15, 16

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

using, in Python 88, 89, 90

assignment expressions 40, 42

asymptotic notation 56

asynchronous code 68, 69, 70

asynchronous context managers 276, 277

asynchronous generators 280, 281

asynchronous iteration 278, 279, 280

asynchronous programming 273, 275

automated testing 287, 288

automatic checks

setup 26, 27

automatic formatting 23, 25

B

behavioral patterns 344

chain of responsibility 345, 347, 348

command 349, 350

state 350, 353, 354, 355

template method 348

black

reference link 24

Borg pattern 334, 335, 336

boundary values 323

builder pattern 336, 337

built-in types

extending 66, 67, 68

C

callable object 61, 63

chain of responsibility 345, 347, 348

class decorators 161, 162, 163, 164, 190, 191

alternative 226, 228, 229

classes

creating, with compact syntax 49, 50, 51, 52

clean architecture 364

clean code 2, 5

significance 3, 4

Coala

reference link 23

code

evolving 316, 317, 318

generic validations 22

structuring 122

tracing 178

code comments 9, 10

code coverage 306

code documentation 9

code duplication 92, 93

code formatting 6

coding guideline 6, 7

cohesion 91

command pattern 349, 350

compact function signatures 118, 119

component testing 287

composite pattern 339

composition 189

comprehension expressions 40, 42

container objects 57, 58, 59

context managers 34, 35, 36

implementing 37, 39, 40

methods 35

Continuous Integration (CI) 19

contract 74

invariants 75

postconditions 75

preconditions 75

side effects 75

coroutines 259, 260

delegating into 268

values, returning in 266, 268

coupling 91

coverage

reference link 306

creational patterns 330

builder 336, 337

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 objects 168, 169

decorator pattern 340, 341, 342

decorators

advanced decorators 165

arguments, passing to 165, 166

benefits 176

clean code 189

common mistakes, avoiding 178

creating 186, 187, 188

data, preserving for original wrapped object 179, 180, 181

descriptors, implementing in 237

extended syntax 175

for classes 160, 161, 162, 163, 164

for coroutines 172, 173, 174

function decorators 159, 160

good decorators, analysis 195, 196

incorrect handling, of side effects 182, 183, 184

in Python 158, 159

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

considerations 374, 375

inverting 150, 151

managing 372, 373, 374

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

delete 207, 209

get 204

set 205, 207

set name 210, 211

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

types 211, 212

weak references, using 224

working 217

descriptors, Python

built-in decorators, for methods 234, 235

functions 230, 231, 232, 233

methods 230, 232, 233

slots 235, 236

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

null object pattern 355, 357

structural patterns 337

working 329, 330

design principles 286

Docker containers 376, 377

docstring 10, 11, 12, 13

documentation 9

domain models 380, 381

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

for objects 59, 61

E

edge cases 324

empty except blocks

avoiding 85, 87

equivalence class 323

error handling 78, 79

events system

extending 135, 136, 137

refactoring, for extensibility 133, 135

exception handling 80, 81

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

function decorators 159, 160

functions

arguments, copying to 107, 108

number of arguments 117

function signatures

adapting 176, 178

functools.partial

reference link 227

G

generator interface, methods 260

close() 260, 261

send(value) 263, 264, 265, 266

throw(ex_type[, ex_value[, ex_traceback]]) 261, 262, 263

generators

creating 242

example 242, 243, 244, 245

expressions 246, 247

using 250, 251

generic validations

in code 22, 23

God objects 126

Graphene

URL 61

GraphQL

URL 61

H

hexagonal architecture (HEX) 368

hint 13

http.server package

reference link 100

I

idioms

for iteration 247, 248, 249

incompatible signatures

detecting, with pylint 140

incorrect method signatures

detecting, with mypy 138, 139

indexes 30, 31

inheritance 189

anti-patterns 100, 101, 102, 103

good case 99, 100

in Python 99

multiple inheritance 103, 104

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

creating 53, 54, 55

iteration

interface 256, 257

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

magic methods 63, 64, 277

maintainability perils

examples 131, 132

maintainability perils

examples 130

Method Resolution Order (MRO) 104, 105

microservices architecture 366

mixin 106

mocking 287

mock objects 309

using 310

mocks 310, 311

types 311, 312

monolithic applications 367

monostate pattern 331

multiple inheritance 103, 104

mutable default arguments 64, 65

mutants 320

mutation testing 320, 321, 322

mypy

reference link 9, 20

used, for detecting incorrect method signatures 138, 139

N

nested loops 253, 254

next() function 249, 250

non-data descriptor 212

non-data descriptors 212, 213, 214

null object pattern 355, 357

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

dynamic attributes 59, 61

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

including 87, 88

P

packages 369, 370, 371, 372

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

postconditions 76, 77

preconditions 76

production code 318, 319

properties 46, 48

property-based testing 320

pylint

used, for detecting incompatible signatures 140

pylint command 22

PyPi

reference link 369

pytest 301

fixtures 304

parameterized tests 303, 304

reference link 294

test cases 302, 303

pytest-cov package 307

Python

assertions, using 88, 89, 90

decorators 158, 159

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

properties 43, 46, 47, 48, 49

underscores 44, 45

Python,features

underscores 46

Pythonic contracts 77

pytype

reference link 9, 20

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

as iterables 257, 258, 259

sequences

creating 32, 33, 56, 57

service-level agreements (SLAs) 366

service-level objectives (SLOs) 366

services 384, 385, 386, 387

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

slices 30, 31

slots 235, 236

software

orthogonality 120, 121

software components 368

Docker containers 376, 377

packages 369, 370, 371, 372

services 384, 385, 386, 387

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

adapter 337, 338, 339

composite 339

decorator 340, 341, 342

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

caveats 308, 309

setting up 307

test double 310

use case 312, 313, 314, 315

test-driven design 289

Test-Driven Design (TDD) 324

test-driven development 325

testing 319, 320

boundaries, defining 293

mutation testing 320, 322

property-based testing 320

themes 323

tools 293

The Cathedral and the Bazaar (CatB) 288

tooling 19

tracebacks, of exceptions 85

tracing 178

trio

reference link 69, 275

type annotations

applying, on descriptors 238

type consistency

checking 20, 21

U

underscores 44, 45, 46

unit test 286, 287

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

use case 378, 379

adapters 383

code 379

domain models 380, 381

uvloop

reference link 275

V

value

capturing, returned by sub-generator 270, 271

values

returning, in coroutines 266, 268

value substitution 79, 80

W

wrapped object 159

wrapper 337

Y

YAGNI (You Ain't Gonna Need It) 94, 95

yapf

reference link 25

yield from syntax 268, 269

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.193.232