Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR] Convert the imports to Google Python Conventions #78

Closed
kopf-archiver bot opened this issue Aug 18, 2020 · 0 comments
Closed

[PR] Convert the imports to Google Python Conventions #78

kopf-archiver bot opened this issue Aug 18, 2020 · 0 comments
Labels
archive automation CI/CD: testing, linting, releasing automatically

Comments

@kopf-archiver
Copy link

kopf-archiver bot commented Aug 18, 2020

A pull request by nolar at 2019-05-27 10:21:51+00:00
Original URL: zalando-incubator/kopf#78
Merged by nolar at 2019-05-28 09:14:32+00:00

Issue : #13

This is a refactoring to switch to the Google Python Style Guide for imports.

This PR contains no changes of the behaviour.
The public signatures remain exactly the same.


Reason: With the old approach (from kopf.mod import func; x = func()), it becomes more and more difficult to patch & mock the cross-module functions, as the patches are needed at where the functions are used, not where they are implemented.

Tracking of what is imported where is difficult on its own, and also implies the knowledge of how the code is done on the multi-level sequences of calls. This violates the concept of the tests testing the behaviour rather than the specific implementation of it.

Now (with this PR: from kopf import mod; x = mod.func()), the functions & constants are patched at where they are implemented (in their own modules), and all places around the code always refer to the function via its module name. We assume that we never mock the whole modules.

The new importing approach is not applied to the tests, and they continue to import individual functions/constants/classes for 2 reasons:

  • The tests use those functions/classes as the objects-under-test, so they need the original functions, not their mocks.
  • To ensure that the tests remain (mostly) unchanged — for easier PR review.

Some renames were necessary to ensure absence of naming conflicts:

  • kopf.reactor.registry is now kopf.reactor.registries, to not collide with the registry= kwarg.
    peering= kwarg is now peering_name= kwarg, to not collide with kopf.reactor.peering module (also implies that the peering modes can be extended with something else in addition to the names).
  • kopf.structs.progress is now kopf.structs.status.
@kopf-archiver kopf-archiver bot closed this as completed Aug 18, 2020
@kopf-archiver kopf-archiver bot changed the title [archival placeholder] [PR] Convert the imports to Google Python Conventions Aug 19, 2020
@kopf-archiver kopf-archiver bot added the automation CI/CD: testing, linting, releasing automatically label Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
archive automation CI/CD: testing, linting, releasing automatically
Projects
None yet
Development

No branches or pull requests

0 participants