Skip to content

Conversation

@ipspace
Copy link
Owner

@ipspace ipspace commented Dec 11, 2025

Reports:

  • All modules/packages used by netlab core (the list is still updated manually)
  • All core ansible components

Resolves #2910

Reports:
* All modules/packages used by netlab core (the list is still updated
  manually)
* All core ansible components

Resolves #2910
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the netlab version command to provide comprehensive reporting of all dependencies used by netlab core and Ansible components. The implementation refactors the version checking logic into reusable functions and uses the modern importlib.metadata API for version detection.

Key changes:

  • Adds tracking for previously unreported core dependencies ('requests', 'filelock', 'rich')
  • Creates a dedicated section for Ansible components (ansible, ansible-core, ansible-pylibssh)
  • Refactors version detection into two specialized functions: module_version() for module-based checks and package_version() for metadata-based checks

print(f' Cannot find {package} version: {str(ex)}')
except Exception as ex:
if package not in MISSING_OK:
print(f' {package}: not installed {str(ex)}')
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

When a package is in MISSING_OK and cannot be imported, no message is printed at all. This creates inconsistent output where MISSING_OK packages silently disappear from the version report. Consider printing a message like "not installed (optional)" for MISSING_OK packages to maintain consistency in the output.

Suggested change
print(f' {package}: not installed {str(ex)}')
print(f' {package}: not installed {str(ex)}')
else:
print(f' {package}: not installed (optional)')

Copilot uses AI. Check for mistakes.

def run(args: typing.List[str]) -> None:
global MODULES, MISSING_OK
global MODULES, PACKAGES, ANSIBLE_PACKAGES, MISSING_OK
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

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

The global declaration is unnecessary since the function only reads these variables without modifying them. Remove the global statement to improve code clarity.

Suggested change
global MODULES, PACKAGES, ANSIBLE_PACKAGES, MISSING_OK

Copilot uses AI. Check for mistakes.
While implementing a Copilog suggestion, I realized it looks better if
we split required and optional packages in two lists
Copy link
Collaborator

@DanPartelly DanPartelly left a comment

Choose a reason for hiding this comment

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

Nice. Thank you, Ivan.

@ipspace ipspace merged commit 949adb4 into dev Dec 11, 2025
11 checks passed
@ipspace ipspace deleted the pkg-ver branch December 11, 2025 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

We miss "requests" in netlab version help

3 participants