Skip to content

Commit

Permalink
Removed unnecessary ClassVar typing for settings
Browse files Browse the repository at this point in the history
  • Loading branch information
igo95862 committed Dec 21, 2022
1 parent dc2f382 commit caec60d
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 21 deletions.
4 changes: 2 additions & 2 deletions sdbus_async/networkmanager/settings/adsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# if possible, please make changes by also updating the script.
from __future__ import annotations
from dataclasses import dataclass, field
from typing import ClassVar, List, Optional
from typing import Optional
from .base import NetworkManagerSettingsMixin


@dataclass
class AdslSettings(NetworkManagerSettingsMixin):
"""ADSL Settings"""
secret_fields_names: ClassVar[List[str]] = ['password']
secret_fields_names = ['password']
secret_name = 'adsl'

encapsulation: Optional[str] = field(
Expand Down
4 changes: 2 additions & 2 deletions sdbus_async/networkmanager/settings/cdma.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# if possible, please make changes by also updating the script.
from __future__ import annotations
from dataclasses import dataclass, field
from typing import ClassVar, List, Optional
from typing import Optional
from .base import NetworkManagerSettingsMixin


@dataclass
class CdmaSettings(NetworkManagerSettingsMixin):
"""CDMA-based Mobile Broadband Settings"""
secret_fields_names: ClassVar[List[str]] = ['password']
secret_fields_names = ['password']
secret_name = 'cdma'

mtu: Optional[int] = field(
Expand Down
4 changes: 2 additions & 2 deletions sdbus_async/networkmanager/settings/eapol.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# if possible, please make changes by also updating the script.
from __future__ import annotations
from dataclasses import dataclass, field
from typing import ClassVar, List, Optional
from typing import List, Optional
from .base import NetworkManagerSettingsMixin


@dataclass
class EapolSettings(NetworkManagerSettingsMixin):
"""IEEE 802.1x Authentication Settings"""
secret_fields_names: ClassVar[List[str]] = ['ca_cert_password', 'client_cert_password', 'password', 'password_raw', 'phase2_ca_cert_password', 'phase2_client_cert_password', 'phase2_private_key_password', 'pin', 'private_key_password']
secret_fields_names = ['ca_cert_password', 'client_cert_password', 'password', 'password_raw', 'phase2_ca_cert_password', 'phase2_client_cert_password', 'phase2_private_key_password', 'pin', 'private_key_password']
secret_name = '802-1x'

altsubject_matches: Optional[List[str]] = field(
Expand Down
4 changes: 2 additions & 2 deletions sdbus_async/networkmanager/settings/gsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# if possible, please make changes by also updating the script.
from __future__ import annotations
from dataclasses import dataclass, field
from typing import ClassVar, List, Optional
from typing import Optional
from .base import NetworkManagerSettingsMixin


@dataclass
class GsmSettings(NetworkManagerSettingsMixin):
"""GSM-based Mobile Broadband Settings"""
secret_fields_names: ClassVar[List[str]] = ['password', 'pin']
secret_fields_names = ['password', 'pin']
secret_name = 'gsm'

apn: Optional[str] = field(
Expand Down
4 changes: 2 additions & 2 deletions sdbus_async/networkmanager/settings/macsec.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# if possible, please make changes by also updating the script.
from __future__ import annotations
from dataclasses import dataclass, field
from typing import ClassVar, List, Optional
from typing import Optional
from .base import NetworkManagerSettingsMixin


@dataclass
class MacsecSettings(NetworkManagerSettingsMixin):
"""MACSec Settings"""
secret_fields_names: ClassVar[List[str]] = ['mka_cak']
secret_fields_names = ['mka_cak']
secret_name = 'macsec'

encrypt: Optional[bool] = field(
Expand Down
4 changes: 2 additions & 2 deletions sdbus_async/networkmanager/settings/pppoe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# if possible, please make changes by also updating the script.
from __future__ import annotations
from dataclasses import dataclass, field
from typing import ClassVar, List, Optional
from typing import Optional
from .base import NetworkManagerSettingsMixin


@dataclass
class PppoeSettings(NetworkManagerSettingsMixin):
"""PPP-over-Ethernet Settings"""
secret_fields_names: ClassVar[List[str]] = ['password']
secret_fields_names = ['password']
secret_name = 'pppoe'

parent: Optional[str] = field(
Expand Down
4 changes: 2 additions & 2 deletions sdbus_async/networkmanager/settings/wireguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# if possible, please make changes by also updating the script.
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Any, ClassVar, List, Optional, Tuple
from typing import Any, List, Optional, Tuple
from .base import NetworkManagerSettingsMixin
from .datatypes import WireguardPeers


@dataclass
class WireguardSettings(NetworkManagerSettingsMixin):
"""WireGuard Settings"""
secret_fields_names: ClassVar[List[str]] = ['private_key']
secret_fields_names = ['private_key']
secret_name = 'wireguard'

fwmark: Optional[int] = field(
Expand Down
4 changes: 2 additions & 2 deletions sdbus_async/networkmanager/settings/wireless_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# if possible, please make changes by also updating the script.
from __future__ import annotations
from dataclasses import dataclass, field
from typing import ClassVar, List, Optional
from typing import List, Optional
from .base import NetworkManagerSettingsMixin


@dataclass
class WirelessSecuritySettings(NetworkManagerSettingsMixin):
"""Wi-Fi Security Settings"""
secret_fields_names: ClassVar[List[str]] = ['leap_password', 'psk']
secret_fields_names = ['leap_password', 'psk']
secret_name = '802-11-wireless-security'

auth_alg: Optional[str] = field(
Expand Down
4 changes: 0 additions & 4 deletions tools/generate-settings-dataclasses-jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ def __init__(self, name: str, description: str, name_upper: str,
def typing_imports(self) -> Set[str]:
typing_imports: Set[str] = self.properties_want_imports.copy()

if self.secret_fields:
typing_imports.add('ClassVar')
typing_imports.add('List')

return typing_imports

@cached_property
Expand Down
2 changes: 1 addition & 1 deletion tools/jinja_templates/setting.py.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ from .datatypes import {{ setting.datatypes_imports|sort|join(', ') }}
class {{ setting.python_class_name }}(NetworkManagerSettingsMixin):
"""{{ setting.description }}"""
{%- if setting.secret_fields %}
secret_fields_names: ClassVar[List[str]] = ['{{ setting.secret_fields|sort|join("', '") }}']
secret_fields_names = ['{{ setting.secret_fields|sort|join("', '") }}']
secret_name = '{{ setting.name }}'
{%- endif %}
{% for property in setting.properties %}
Expand Down

0 comments on commit caec60d

Please sign in to comment.