-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Open
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.Denotes an issue or PR has remained open with no activity and has become stale.
Description
What happened (please include outputs or screenshots):
Calls to parse_quantity work, but format_quantity do not, even though they are in the same file
from kubernetes import utils
decimal = utils.parse_quantity("1234Ki")
result = utils.format_quantity(decimal,"Mi")
print(result)
returns
Traceback (most recent call last):
File "/home/dferguson/tmp/py_k8s/./t1.py", line 3, in <module>
result = utils.format_quantity(decimal,"Mi") # format_quantity not found
^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'kubernetes.utils' has no attribute 'format_quantity'. Did you mean: 'parse_quantity'?
whereas:
from kubernetes.utils import quantity
decimal = quantity.parse_quantity("1234Ki")
result = quantity.format_quantity(decimal,"Mi")
print(result)
works as expected
What you expected to happen:
Using utils.format_quantity finds the function correctly
How to reproduce it (as minimally and precisely as possible):
See above
Anything else we need to know?:
Easily fixed by amending kubernetes/utils/__init__.py
-from .quantity import parse_quantity
+from .quantity import parse_quantity,format_quantity
Quicker to type up the issue in here rather than fork/pull request for such a small fix
Environment:
- Kubernetes version (
kubectl version):
Client Version: v1.32.0
Kustomize Version: v5.5.0
Server Version: v1.31.9-eks-5d4a308
- OS (e.g., MacOS 10.13.6): Windows WSL2
5.15.167.4-microsoft-standard-WSL2 - Python version (
python --version):Python 3.12.3 - Python client version (
pip list | grep kubernetes):kubernetes 33.1.0
Metadata
Metadata
Assignees
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.Denotes an issue or PR has remained open with no activity and has become stale.