Fixed double module imports

In Python, when you write `import foo.bar.baz` this means that the modules would be imported and the name `foo` will be bound locally and becomes available in the module. https://docs.python.org/3/reference/simple_stmts.html#import

So, doing `import kubernetes.client` leads to name `kubernetes` (not `client`) being added to the `kubernetes` module leading to a weird duplicate nesting. See:
```
>>> import kubernetes
>>> kubernetes
<module 'kubernetes' from 'C:\\Users\\Ark\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\kubernetes\\__init__.py'>
>>> kubernetes.kubernetes
<module 'kubernetes' from 'C:\\Users\\Ark\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\kubernetes\\__init__.py'>
```

We can solve this issues by using the `import ... from ...` syntax: Replace `import kubernetes.client` with `from kubernetes import client`.

I see that most modules already use relative imports, so I'm using relative imports here as well: `from . import client`.
This commit is contained in:
Alexey Volkov 2022-10-23 17:50:50 -07:00 committed by GitHub
parent 4dddad8dc4
commit a4189ccf4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
# Copyright 2016 The Kubernetes Authors.
# Copyright 2022 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -16,10 +16,10 @@ __project__ = 'kubernetes'
# The version is auto-updated. Please do not edit.
__version__ = "25.0.0-snapshot"
import kubernetes.client
import kubernetes.config
import kubernetes.dynamic
import kubernetes.watch
import kubernetes.stream
import kubernetes.utils
import kubernetes.leaderelection
from . import client
from . import config
from . import dynamic
from . import watch
from . import stream
from . import utils
from . import leaderelection