Skip to content

Clean up methods which return self #776

@dhermes

Description

@dhermes

See https://github.com/GoogleCloudPlatform/gcloud-python/pull/770/files#r27422508

return self is a JavaScript-y method chaining construct.

In Python

foo = Foo()
foo2 = foo.update()

indicates that foo2 is indeed a Foo object, but that foo.update() has applied the changes without mutating foo. Using return self breaks that expectation.

For example on list

>>> a = [3, -4, 1, 0]
>>> b = a.sort()
>>> b is None
True
>>> a
[-4, 0, 1, 3]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions