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

Make the sphinx check more resilient #17701

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JacobCallahan
Copy link
Member

Just saw an issue in the robottelo CI where this popped up.

  File "/home/runner/work/robottelo/robottelo/robottelo/config/__init__.py", line 25, in get_settings
    if builtins.__sphinx_build__:
       ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'builtins' has no attribute '__sphinx_build__'

If we simply make this a getattr call, then we don't have to worry about that attribute being present.

@JacobCallahan JacobCallahan added CherryPick PR needs CherryPick to previous branches 6.14.z Introduced in or relating directly to Satellite 6.14 6.15.z Introduced in or relating directly to Satellite 6.15 6.16.z Introduced in or relating directly to Satellite 6.16 6.17.z labels Feb 26, 2025
@JacobCallahan JacobCallahan self-assigned this Feb 26, 2025
@JacobCallahan JacobCallahan requested a review from a team as a code owner February 26, 2025 21:48

Choose a reason for hiding this comment

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

PR Overview

This PR aims to improve the resilience of the Sphinx build check by replacing a direct attribute access with a getattr call.

  • Replace direct attribute access with getattr for builtins.sphinx_build
  • Maintain fallback behavior when the attribute is missing

Reviewed Changes

File Description
robottelo/config/init.py Use getattr for the sphinx build check to avoid AttributeError

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

robottelo/config/init.py:27

  • Since hasattr is now enforced by using getattr with a default value, the AttributeError block should never be triggered. Consider removing the try/except block to simplify the code.
except AttributeError:
Just saw an issue in the robottelo CI where this popped up.

  File "/home/runner/work/robottelo/robottelo/robottelo/config/__init__.py", line 25, in get_settings
    if builtins.__sphinx_build__:
       ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'builtins' has no attribute '__sphinx_build__'

If we simply make this a getattr call, then we don't have to worry about that attribute being present.

Choose a reason for hiding this comment

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

PR Overview

This PR improves the resilience of the sphinx build check by replacing the try/except block with an inline getattr call on the builtins module.

  • Replaces exception-based attribute access with getattr
  • Returns early when sphinx_build is set to a truthy value
  • Simplifies the control flow for clarity

Reviewed Changes

File Description
robottelo/config/init.py Updated the sphinx build check to use getattr and return early

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

@JacobCallahan
Copy link
Member Author

Great review by Copilot! Expanded the scope a bit thanks to the feedback.

@Gauravtalreja1
Copy link
Collaborator

trigger: test-robottelo

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 10334
Build Status: UNSTABLE
PRT Comment: pytest /opt/app-root/src/robottelo/tests/foreman -v -m build_sanity --external-logging
Test Result : = 12 passed, 1 skipped, 5615 deselected, 6175 warnings, 1 error in 4651.69s (1:17:31) =

@Satellite-QE Satellite-QE added the PRT-Failed Indicates that latest PRT run is failed for the PR label Feb 27, 2025
@JacobCallahan
Copy link
Member Author

The single PRT error is unrelated to this change.

@JacobCallahan JacobCallahan added PRT-Passed Indicates that latest PRT run is passed for the PR and removed PRT-Failed Indicates that latest PRT run is failed for the PR labels Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.14.z Introduced in or relating directly to Satellite 6.14 6.15.z Introduced in or relating directly to Satellite 6.15 6.16.z Introduced in or relating directly to Satellite 6.16 6.17.z CherryPick PR needs CherryPick to previous branches PRT-Passed Indicates that latest PRT run is passed for the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants