Skip to content

Added Type Annotations #219

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

Merged
merged 1 commit into from
Feb 21, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions adafruit_platformdetect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
Attempt to detect the current platform.
"""
import re

from adafruit_platformdetect.board import Board
from adafruit_platformdetect.chip import Chip
from typing import Optional
from .board import Board
from .chip import Chip


# Various methods here may retain state in future, so tell pylint not to worry
Expand All @@ -17,11 +17,11 @@
class Detector:
"""Wrap various platform detection functions."""

def __init__(self):
def __init__(self) -> None:
self.board = Board(self)
self.chip = Chip(self)

def get_cpuinfo_field(self, field):
def get_cpuinfo_field(self, field: str) -> Optional[str]:
"""
Search /proc/cpuinfo for a field and return its value, if found,
otherwise None.
Expand All @@ -37,7 +37,7 @@ def get_cpuinfo_field(self, field):
return match.group(1)
return None

def check_dt_compatible_value(self, value):
def check_dt_compatible_value(self, value: str) -> bool:
"""
Search /proc/device-tree/compatible for a value and return True, if found,
otherwise False.
Expand All @@ -49,7 +49,7 @@ def check_dt_compatible_value(self, value):

return False

def get_armbian_release_field(self, field):
def get_armbian_release_field(self, field: str) -> Optional[str]:
"""
Search /etc/armbian-release, if it exists, for a field and return its
value, if found, otherwise None.
Expand All @@ -69,7 +69,7 @@ def get_armbian_release_field(self, field):

return field_value

def get_device_model(self):
def get_device_model(self) -> Optional[str]:
"""
Search /proc/device-tree/model for the device model and return its value, if found,
otherwise None.
Expand All @@ -81,7 +81,7 @@ def get_device_model(self):
pass
return None

def get_device_compatible(self):
def get_device_compatible(self) -> Optional[str]:
"""
Search /proc/device-tree/compatible for the compatible chip name.
"""
Expand All @@ -94,7 +94,7 @@ def get_device_compatible(self):
pass
return None

def check_board_asset_tag_value(self):
def check_board_asset_tag_value(self) -> Optional[str]:
"""
Search /sys/devices/virtual/dmi/id for the device model and return its value, if found,
otherwise None.
Expand All @@ -108,7 +108,7 @@ def check_board_asset_tag_value(self):
pass
return None

def check_board_name_value(self):
def check_board_name_value(self) -> Optional[str]:
"""
Search /sys/devices/virtual/dmi/id for the board name and return its value, if found,
otherwise None. Debian/ubuntu based
Expand Down
Loading