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

Use versioned links to docs #819

Merged
merged 1 commit into from Feb 22, 2022
Merged

Use versioned links to docs #819

merged 1 commit into from Feb 22, 2022

Conversation

ericwb
Copy link
Member

@ericwb ericwb commented Feb 20, 2022

In the report of a Bandit run, there are links to the docs as
part of the more information. Today, these links are always
to the latest docs. So depending on the version of Bandit you're
running, these links could contain inaccurate information for
that version.

That's why this change makes it so a specific version of Bandit
is pinned to refer to a specific version of documentation.

Signed-off-by: Eric Brown browne@vmware.com

import bandit


BASE_URL = "https://bandit.readthedocs.io/"
Copy link
Member

Choose a reason for hiding this comment

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

Why not do something like:

BASE_URL = f"https://bandit.readthedocs.io/en/{bandit.__version__}/"

And then keep the rest of the code simpler?

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense, will change it.

Copy link
Member Author

@ericwb ericwb Feb 20, 2022

Choose a reason for hiding this comment

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

Hmm, not sure why, but using bandit.version as a global here causes stevedore to fail to load any extensions.

Copy link
Member Author

@ericwb ericwb Feb 21, 2022

Choose a reason for hiding this comment

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

I added a failure callback to the extension loader of Stevedore and get this
module 'bandit' has no attribute '__version__'
So root cause is that because BASE_URL is a global and calling into bandit module before it has been loaded, there is no such attribute.

Copy link
Member Author

Choose a reason for hiding this comment

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

Think I can fix a few ways:

  1. revert to previous change
  2. move BASE_URL into the get_url() function. Seems BASE_URL is only global for the unit test purposes
  3. use pbr.version.VersionInfo("bandit").version_string() instead of bandit.version

Copy link
Member Author

Choose a reason for hiding this comment

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

I went with option 2.

In the report of a Bandit run, there are links to the docs as
part of the more information. Today, these links are always
to the latest docs. So depending on the version of Bandit you're
running, these links could contain inaccurate information for
that version.

That's why this change makes it so a specific version of Bandit
is pinned to refer to a specific version of documentation.

Signed-off-by: Eric Brown <browne@vmware.com>
@ericwb ericwb added this to the Release 1.7.3 milestone Feb 21, 2022
@ericwb ericwb merged commit 7fbf9d5 into PyCQA:main Feb 22, 2022
@ericwb ericwb deleted the ver_docs branch February 22, 2022 00:58
This was referenced Feb 28, 2022
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.

None yet

2 participants