-
Notifications
You must be signed in to change notification settings - Fork 994
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
support python3.12 #2290
support python3.12 #2290
Conversation
|
WalkthroughThe recent update in the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -161,7 +160,7 @@ def output_to_sarif( | |||
"driver": { | |||
"name": "Slither", | |||
"informationUri": "https://github.com/crytic/slither", | |||
"version": require("slither-analyzer")[0].version, | |||
"version": metadata.version("slither-analyzer"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that metadata.version("slither-analyzer")
is wrapped in a try-except block to handle PackageNotFoundError
in case the package is not found.
slither/__main__.py
Outdated
if sys.version_info >= (3, 10): | ||
entry_points = metadata.entry_points(group="slither_analyzer.plugin") | ||
else: | ||
from pkg_resources import iter_entry_points | ||
entry_points = iter_entry_points(group="slither_analyzer.plugin", name=None) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider simplifying the conditional import logic for entry_points
by directly using metadata.entry_points(group="slither_analyzer.plugin")
, as the minimum supported Python version is now 3.10.
@@ -297,7 +302,7 @@ def parse_args( | |||
parser.add_argument( | |||
"--version", | |||
help="displays the current version", | |||
version=require("slither-analyzer")[0].version, | |||
version=metadata.version("slither-analyzer"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that metadata.version("slither-analyzer")
is wrapped in a try-except block to handle PackageNotFoundError
in case the package is not found.
93cbf7d
to
410119a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (2)
- slither/main.py (3 hunks)
- slither/utils/output.py (2 hunks)
Files skipped from review as they are similar to previous changes (2)
- slither/main.py
- slither/utils/output.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @branchvincent! This looks good!
NB @0xalpharush I have not manually confirmed if the plugin system remains working on 3.10+ and I don't think we have an automated test for that.
@@ -166,7 +165,14 @@ def get_detectors_and_printers() -> Tuple[ | |||
printers = [p for p in printers_ if inspect.isclass(p) and issubclass(p, AbstractPrinter)] | |||
|
|||
# Handle plugins! | |||
for entry_point in iter_entry_points(group="slither_analyzer.plugin", name=None): | |||
if sys.version_info >= (3, 10): | |||
entry_points = metadata.entry_points(group="slither_analyzer.plugin") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be possible to use this implementation in 3.8+ as well if we added a dependency on importlib_metadata >= 3.6
and imported metadata
through it.
We should update this to run 3.8 and 3.12 on every PR and run 3.8-3.12. slither/.github/workflows/test.yml Line 28 in 1bd279a
|
@branchvincent Would you be willing to sign the CLA please? |
@branchvincent bump |
@elopez I guess we are going to have to reopen this ourselves since the OP is unresponsive |
sorry about that, I have to check with my employer before signing the CLA. alternatively, I'm more than happy for you to just create the same PR |
replaced by #2348 |
Python 3.12 has removed its bundled
setuptools
(akapkg_resources
): https://docs.python.org/3.12/whatsnew/3.12.html#removedSummary by CodeRabbit
slither-analyzer
, ensuring compatibility with Python 3.10.pkg_resources
withimportlib.metadata
for handling entry points and version information retrieval.output_to_sarif
function to usemetadata
instead ofrequire
.