From 8a5c76e5fe1e52196689dc6a56de1688d372bcd0 Mon Sep 17 00:00:00 2001 From: Praven Kuttappan <55455725+praveenkuttappan@users.noreply.github.com> Date: Fri, 17 Nov 2023 11:47:48 -0500 Subject: [PATCH] Set package version in API review code File for Python (#7305) * Set package version in API review code File for Python --- .../python-packages/apiview-stub-generator/CHANGELOG.md | 5 ++++- .../apiview-stub-generator/apistub/_apiview.py | 5 +++-- .../apiview-stub-generator/apistub/_stub_generator.py | 7 ++++--- .../apiview-stub-generator/apistub/_version.py | 2 +- .../apiview-stub-generator/apiview_reqs.txt | 3 ++- .../APIView/APIViewWeb/Languages/PythonLanguageService.cs | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/python-packages/apiview-stub-generator/CHANGELOG.md b/packages/python-packages/apiview-stub-generator/CHANGELOG.md index ed495eae1fe..6606934ffa4 100644 --- a/packages/python-packages/apiview-stub-generator/CHANGELOG.md +++ b/packages/python-packages/apiview-stub-generator/CHANGELOG.md @@ -1,6 +1,9 @@ # Release History -## Version 0.3.9 (TBD) +## Version 0.3.10 (2023-11-17) +Update package version in API review codefile + +## Version 0.3.9 (2023-11-17) Improve support for "CrossLanguageDefinitionId". ## Version 0.3.8 (2023-07-06) diff --git a/packages/python-packages/apiview-stub-generator/apistub/_apiview.py b/packages/python-packages/apiview-stub-generator/apistub/_apiview.py index 7f91c3bf468..4913fadf6f0 100644 --- a/packages/python-packages/apiview-stub-generator/apistub/_apiview.py +++ b/packages/python-packages/apiview-stub-generator/apistub/_apiview.py @@ -12,7 +12,7 @@ from ._diagnostic import Diagnostic from ._metadata_map import MetadataMap -JSON_FIELDS = ["Name", "Version", "VersionString", "Navigation", "Tokens", "Diagnostics", "PackageName", "Language"] +JSON_FIELDS = ["Name", "Version", "VersionString", "Navigation", "Tokens", "Diagnostics", "PackageName", "Language", "PackageVersion"] HEADER_TEXT = "# Package is parsed using apiview-stub-generator(version:{0}), Python version: {1}".format(VERSION, platform.python_version()) TYPE_NAME_REGEX = re.compile(r"(~?[a-zA-Z\d._]+)") @@ -40,7 +40,7 @@ def get_root_path(cls): path = os.path.split(path)[0] return None - def __init__(self, *, pkg_name="", namespace = "", metadata_map=None, source_url=None): + def __init__(self, *, pkg_name="", namespace = "", metadata_map=None, source_url=None, pkg_version =""): self.name = pkg_name self.version = 0 self.version_string = VERSION @@ -52,6 +52,7 @@ def __init__(self, *, pkg_name="", namespace = "", metadata_map=None, source_url self.namespace = namespace self.node_index = NodeIndex() self.package_name = pkg_name + self.package_version = pkg_version self.metadata_map = metadata_map or MetadataMap("") self.add_token(Token("", TokenKind.SkipDiffRangeStart)) self.add_literal(HEADER_TEXT) diff --git a/packages/python-packages/apiview-stub-generator/apistub/_stub_generator.py b/packages/python-packages/apiview-stub-generator/apistub/_stub_generator.py index 0bf9639d5da..1dc002b72cf 100644 --- a/packages/python-packages/apiview-stub-generator/apistub/_stub_generator.py +++ b/packages/python-packages/apiview-stub-generator/apistub/_stub_generator.py @@ -143,7 +143,7 @@ def generate_tokens(self): namespace = self.filter_namespace logging.debug("Generating tokens") - apiview = self._generate_tokens(pkg_root_path, pkg_name, namespace, source_url=self.source_url) + apiview = self._generate_tokens(pkg_root_path, pkg_name, namespace, version, source_url=self.source_url) if apiview.diagnostics: logging.info("*************** Completed parsing package with errors ***************") else: @@ -189,7 +189,7 @@ def _find_modules(self, pkg_root_path): return sorted(modules) - def _generate_tokens(self, pkg_root_path, package_name, namespace, *, source_url): + def _generate_tokens(self, pkg_root_path, package_name, namespace, package_version, *, source_url): """This method returns a dictionary of namespace and all public classes in each namespace """ # Import ModuleNode. @@ -203,7 +203,8 @@ def _generate_tokens(self, pkg_root_path, package_name, namespace, *, source_url pkg_name=package_name, namespace=namespace, metadata_map=mapping, - source_url=source_url + source_url=source_url, + pkg_version=package_version ) modules = self._find_modules(pkg_root_path) logging.debug("Modules to generate tokens: {}".format(modules)) diff --git a/packages/python-packages/apiview-stub-generator/apistub/_version.py b/packages/python-packages/apiview-stub-generator/apistub/_version.py index 0434266ad0e..ed2fdbc4d1d 100644 --- a/packages/python-packages/apiview-stub-generator/apistub/_version.py +++ b/packages/python-packages/apiview-stub-generator/apistub/_version.py @@ -1,4 +1,4 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -VERSION = "0.3.9" +VERSION = "0.3.10" diff --git a/packages/python-packages/apiview-stub-generator/apiview_reqs.txt b/packages/python-packages/apiview-stub-generator/apiview_reqs.txt index 45ad91cf237..3d276f2a227 100644 --- a/packages/python-packages/apiview-stub-generator/apiview_reqs.txt +++ b/packages/python-packages/apiview-stub-generator/apiview_reqs.txt @@ -1,2 +1,3 @@ ./ -pylint-guidelines-checker==0.0.7 \ No newline at end of file +pylint-guidelines-checker==0.0.7 +pylint<3.0.0 \ No newline at end of file diff --git a/src/dotnet/APIView/APIViewWeb/Languages/PythonLanguageService.cs b/src/dotnet/APIView/APIViewWeb/Languages/PythonLanguageService.cs index 6353b195c8d..fbc1f6250ad 100644 --- a/src/dotnet/APIView/APIViewWeb/Languages/PythonLanguageService.cs +++ b/src/dotnet/APIView/APIViewWeb/Languages/PythonLanguageService.cs @@ -17,7 +17,7 @@ public class PythonLanguageService : LanguageProcessor { public override string Name { get; } = "Python"; public override string[] Extensions { get; } = { ".whl" }; - public override string VersionString { get; } = "0.3.8"; + public override string VersionString { get; } = "0.3.10"; private readonly string _pythonExecutablePath; public override string ProcessName => _pythonExecutablePath;