Skip to content
Open
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
10 changes: 10 additions & 0 deletions sonic_platform_base/sfp_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,16 @@ def get_power_override(self):
"""
raise NotImplementedError

def get_power_override_support(self):
"""
Retrieves whether power override is supported by this SFP

Returns:
bool: True if power override is supported, False if not supported
None: if not implemented or xcvr_api is not available
"""
return None

def get_temperature(self):
"""
Retrieves the temperature of this SFP
Expand Down
10 changes: 10 additions & 0 deletions sonic_platform_base/sonic_xcvr/sfp_optoe_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,16 @@ def rx_disable_channel(self, channel, disable):
api = self.get_xcvr_api()
return api.rx_disable_channel(channel, disable) if api is not None else None

def get_power_override_support(self):
"""
Retrieves whether power override is supported by this SFP

Returns:
bool: True if power override is supported, False if not supported
None: if xcvr_api is not available
"""
api = self.get_xcvr_api()
return api.get_power_override_support() if api is not None else None
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation returns None when get_xcvr_api() is unavailable, but the new SfpBase API contract describes a boolean return value. Consider returning False when api is None (treat as unsupported) or update the SfpBase docstring/contract to explicitly allow None for read/initialization failures, so callers can rely on a consistent type.

Suggested change
return api.get_power_override_support() if api is not None else None
return api.get_power_override_support() if api is not None else False

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed API description to indicate that None is a valid return value. As noted in my other response, returning False here is incorrect.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arista-hpandya can you add the doc text in the py function briefly describing the return value and what it does?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, added a docstring to the function


def get_power_override(self):
api = self.get_xcvr_api()
Expand Down
Loading