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

lint: fix tip-flake8 and tip-mypy #1896

Merged
merged 3 commits into from Dec 7, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cloudinit/config/cc_ansible.py
Expand Up @@ -132,7 +132,7 @@ def install(self, pkg_name: str):
if not self.is_installed():
# bootstrap pip if required
try:
import pip # type: ignore # noqa: F401
import pip # noqa: F401
except ImportError:
self.distro.install_packages(self.distro.pip_package_name)
cmd = [sys.executable, "-m", "pip", "install"]
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/config/schema.py
Expand Up @@ -382,7 +382,7 @@ def validate_cloudconfig_metaschema(validator, schema: dict, throw=True):

def validate_cloudconfig_schema(
config: dict,
schema: dict = None,
schema: Optional[dict] = None,
strict: bool = False,
strict_metaschema: bool = False,
log_details: bool = True,
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/net/activators.py
Expand Up @@ -97,7 +97,7 @@ class IfUpDownActivator(NetworkActivator):
# E.g., NetworkManager has a ifupdown plugin that requires the name
# of a specific connection.
@staticmethod
def available(target: str = None) -> bool:
def available(target: Optional[str] = None) -> bool:
"""Return true if ifupdown can be used on this system."""
return eni_available(target=target)

Expand Down
6 changes: 3 additions & 3 deletions cloudinit/net/ephemeral.py
Expand Up @@ -4,7 +4,7 @@
"""
import contextlib
import logging
from typing import Any, Dict, List
from typing import Any, Dict, List, Optional

import cloudinit.net as net
from cloudinit import subp
Expand Down Expand Up @@ -35,7 +35,7 @@ def __init__(
prefix_or_mask,
broadcast,
router=None,
connectivity_url_data: Dict[str, Any] = None,
connectivity_url_data: Optional[Dict[str, Any]] = None,
static_routes=None,
):
"""Setup context manager and validate call signature.
Expand Down Expand Up @@ -313,7 +313,7 @@ class EphemeralDHCPv4:
def __init__(
self,
iface=None,
connectivity_url_data: Dict[str, Any] = None,
connectivity_url_data: Optional[Dict[str, Any]] = None,
dhcp_log_func=None,
tmp_dir=None,
):
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/net/network_state.py
Expand Up @@ -251,7 +251,7 @@ def __init__(
self,
version=NETWORK_STATE_VERSION,
config=None,
renderer=None, # type: Optional[Renderer]
renderer: "Optional[Renderer]" = None,
):
self._version = version
self._config = config
Expand Down
2 changes: 1 addition & 1 deletion cloudinit/stages.py
Expand Up @@ -43,7 +43,7 @@ def update_event_enabled(
datasource: sources.DataSource,
cfg: dict,
event_source_type: EventType,
scope: EventScope = None,
scope: Optional[EventScope] = None,
) -> bool:
"""Determine if a particular EventType is enabled.

Expand Down
8 changes: 4 additions & 4 deletions cloudinit/url_helper.py
Expand Up @@ -375,7 +375,7 @@ def _run_func_with_delay(
addr: str,
timeout: int,
event: threading.Event,
delay: float = None,
delay: Optional[float] = None,
) -> Any:
"""Execute func with optional delay"""
if delay:
Expand Down Expand Up @@ -476,11 +476,11 @@ def wait_for_url(
max_wait=None,
timeout=None,
status_cb: Callable = LOG.debug, # some sources use different log levels
headers_cb: Callable = None,
headers_cb: Optional[Callable] = None,
headers_redact=None,
sleep_time: int = 1,
exception_cb: Callable = None,
sleep_time_cb: Callable[[Any, int], int] = None,
exception_cb: Optional[Callable] = None,
sleep_time_cb: Optional[Callable[[Any, int], int]] = None,
request_method: str = "",
connect_synchronously: bool = True,
async_delay: float = 0.150,
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Expand Up @@ -25,6 +25,7 @@ module = [
"jsonpatch",
"netifaces",
"paramiko.*",
"pip.*",
"pycloudlib.*",
"responses",
"serial",
Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tests/modules/test_combined.py
Expand Up @@ -154,8 +154,8 @@ def test_runcmd(self, class_client: IntegrationInstance):
def test_snap(self, class_client: IntegrationInstance):
"""Integration test for the snap module.

This test specifies a command to be executed by the ``snap`` module
and then checks that if that command was executed during boot.
This test verify that the snap packages specified in the user-data
were installed by the ``snap`` module during boot.
"""
client = class_client
snap_output = client.execute("snap list")
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/config/test_cc_ansible.py
Expand Up @@ -18,7 +18,7 @@
from tests.unittests.util import get_cloud

try:
import pip as _pip # type: ignore # noqa: F401
import pip as _pip # noqa: F401

HAS_PIP = True
except ImportError:
Expand Down