Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cloudinit/config/cc_mounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def suggested_swapsize(memsize=None, maxsize=None, fsys=None):
if memsize is None:
memsize = util.read_meminfo()["total"]

GB = 2 ** 30
GB = 2**30
sugg_max = 8 * GB

info = {"avail": "na", "max_in": maxsize, "mem": memsize}
Expand Down Expand Up @@ -230,7 +230,7 @@ def suggested_swapsize(memsize=None, maxsize=None, fsys=None):

info["size"] = size

MB = 2 ** 20
MB = 2**20
pinfo = {}
for k, v in info.items():
if isinstance(v, int):
Expand Down Expand Up @@ -324,7 +324,7 @@ def setup_swapfile(fname, size=None, maxsize=None):
fsys=swap_dir, maxsize=maxsize, memsize=memsize
)

mibsize = str(int(size / (2 ** 20)))
mibsize = str(int(size / (2**20)))
if not size:
LOG.debug("Not creating swap: suggested size was 0")
return
Expand Down
15 changes: 6 additions & 9 deletions cloudinit/stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,15 +871,12 @@ def apply_network_config(self, bring_up):
return

def event_enabled_and_metadata_updated(event_type):
return (
update_event_enabled(
datasource=self.datasource,
cfg=self.cfg,
event_source_type=event_type,
scope=EventScope.NETWORK,
)
and self.datasource.update_metadata_if_supported([event_type])
)
return update_event_enabled(
datasource=self.datasource,
cfg=self.cfg,
event_source_type=event_type,
scope=EventScope.NETWORK,
) and self.datasource.update_metadata_if_supported([event_type])

def should_run_on_boot_event():
return (
Expand Down
4 changes: 2 additions & 2 deletions cloudinit/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2664,7 +2664,7 @@ def pathprefix2dict(base, required=None, optional=None, delim=os.path.sep):
def read_meminfo(meminfo="/proc/meminfo", raw=False):
# read a /proc/meminfo style file and return
# a dict with 'total', 'free', and 'available'
mpliers = {"kB": 2 ** 10, "mB": 2 ** 20, "B": 1, "gB": 2 ** 30}
mpliers = {"kB": 2**10, "mB": 2**20, "B": 1, "gB": 2**30}
kmap = {
"MemTotal:": "total",
"MemFree:": "free",
Expand Down Expand Up @@ -2694,7 +2694,7 @@ def human2bytes(size):
if size.endswith("B"):
size = size[:-1]

mpliers = {"B": 1, "K": 2 ** 10, "M": 2 ** 20, "G": 2 ** 30, "T": 2 ** 40}
mpliers = {"B": 1, "K": 2**10, "M": 2**20, "G": 2**30, "T": 2**40}

num = size
mplier = "B"
Expand Down
4 changes: 2 additions & 2 deletions tests/unittests/test_merging.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _old_mergemanydict(*args):

def _random_str(rand):
base = ""
for _i in range(rand.randint(1, 2 ** 8)):
for _i in range(rand.randint(1, 2**8)):
base += rand.choice(string.ascii_letters + string.digits)
return base

Expand Down Expand Up @@ -81,7 +81,7 @@ def _make_dict(current_depth, max_depth, rand):
if t in [tuple]:
base = tuple(base)
elif t in [int]:
base = rand.randint(0, 2 ** 8)
base = rand.randint(0, 2**8)
elif t in [str]:
base = _random_str(rand)
return base
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ passenv=
PYTEST_ADDOPTS

[format_deps]
black==21.12b0
black==22.3.0
flake8==3.9.2
isort==5.10.1
mypy==0.931
Expand Down