-
Notifications
You must be signed in to change notification settings - Fork 49
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
Added a method to provide plugin information that is included in artifact zip #166
Conversation
@@ -49,7 +49,7 @@ repos: | |||
- id: bandit | |||
files: ^(src|python)/ | |||
- repo: https://github.com/pre-commit/mirrors-mypy | |||
rev: v0.711 | |||
rev: v0.790 |
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.
Upgraded mypy because of python/mypy#9916.
@@ -233,6 +238,37 @@ def _make_pip_command(base_path): | |||
str(base_path / "build"), | |||
] | |||
|
|||
@staticmethod | |||
def _get_plugin_information(project): |
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.
# C812, C815, W503 clash with black, F723 false positive | ||
ignore = E501,C812,C815,C816,W503,F723 | ||
# C812, C815, E203, W503 clash with black, F723 false positive | ||
ignore = E203,E501,C812,C815,C816,W503,F723 |
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.
Added this because of line 251 in codegen.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.
why? can u remove whitespace instead?
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.
black add space here and flake8 complains.
@@ -14,7 +14,7 @@ def recast_object( | |||
if not isinstance(json_data, dict): | |||
raise InvalidRequest(f"Can only parse dict items, not {type(json_data)}") | |||
# if type is Any, we leave it as is | |||
if cls == typing.Any: | |||
if cls is typing.Any: |
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.
Made this change because of pylint error,
W0143: Comparing against a callable, did you omit the parenthesis? (comparison-with-callable)
@@ -233,6 +238,37 @@ def _make_pip_command(base_path): | |||
str(base_path / "build"), | |||
] | |||
|
|||
@staticmethod | |||
def _get_plugin_information(project): |
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.
plz follow repo coding style - annotations are required, method description would be useful as well
requirements_file = project.root / "requirements.txt" | ||
plugin_version = None | ||
|
||
with open(requirements_file) as f: | ||
line = f.readline() | ||
while line: | ||
line = line.strip() | ||
if line.startswith(SUPPORT_LIB_NAME): | ||
line_without_prefix = line[len(SUPPORT_LIB_NAME) :] | ||
|
||
semi_colon = ";" | ||
if semi_colon in line_without_prefix: | ||
index = line_without_prefix.index(semi_colon) | ||
line_without_prefix = line_without_prefix[0:index].strip() | ||
|
||
plugin_version = re.split("=\\s*", line_without_prefix.strip())[-1] | ||
break | ||
|
||
line = f.readline() | ||
|
||
plugin_info = { | ||
"plugin-tool-version": __version__, | ||
"plugin-name": "python", | ||
} | ||
if plugin_version and plugin_version is not None: | ||
plugin_info["plugin-version"] = plugin_version | ||
|
||
return plugin_info |
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.
I would not pick the version from requirements file, as we statically specify >=2.1.3
I don't think lib version can be available during the boiler plate setup. The lib is pulled from PyPi after the repo is setup
# C812, C815, W503 clash with black, F723 false positive | ||
ignore = E501,C812,C815,C816,W503,F723 | ||
# C812, C815, E203, W503 clash with black, F723 false positive | ||
ignore = E203,E501,C812,C815,C816,W503,F723 |
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.
why? can u remove whitespace instead?
Closing this on behalf of #167 |
Description of changes:
Added a method to provide plugin information that is included in artifact zip.
Plugin information includes,
I used information from the pip Requirement Specifiers document to write the parsing logic to fetch the "plugin-version" from the project's requirements.txt file.
I also updated the mypy version and made few other changes based on pre-commit run.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.