From ae61b954bde92751a0a1660971df6a2befcfd8a2 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 8 Jan 2025 15:34:50 -0500 Subject: [PATCH 1/6] don't add too-many-lines disable if already exists --- packages/http-client-python/generator/pygen/black.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/http-client-python/generator/pygen/black.py b/packages/http-client-python/generator/pygen/black.py index 39dee18947..01dbcb1b2c 100644 --- a/packages/http-client-python/generator/pygen/black.py +++ b/packages/http-client-python/generator/pygen/black.py @@ -60,7 +60,7 @@ def format_file(self, file: Path) -> None: except: _LOGGER.error("Error: failed to format %s", file) raise - if len(file_content.splitlines()) > 1000: + if len(file_content.splitlines()) > 1000 and "pylint: disable=too-many-lines" not in file_content: file_content = "# pylint: disable=too-many-lines\n" + file_content self.write_file(file, file_content) From d3d4ba1fb7f21e899c773207e1604c638b3419a1 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 8 Jan 2025 15:36:35 -0500 Subject: [PATCH 2/6] add package.json and changelog --- packages/http-client-python/CHANGELOG.md | 6 ++++++ .../mock_api_tests/test_resiliency_srv_driven_async.py | 1 + packages/http-client-python/micropip.lock | 0 packages/http-client-python/package.json | 2 +- 4 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 packages/http-client-python/micropip.lock diff --git a/packages/http-client-python/CHANGELOG.md b/packages/http-client-python/CHANGELOG.md index c72de8a4ad..092f35c97c 100644 --- a/packages/http-client-python/CHANGELOG.md +++ b/packages/http-client-python/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log - @typespec/http-client-python +## 0.5.2 + +### Bug Fixes + +- Only add linting disables for a file with too many lines if the file doesn't already disable this linter rule + ## 0.5.1 ### Bug Fixes diff --git a/packages/http-client-python/generator/test/azure/mock_api_tests/test_resiliency_srv_driven_async.py b/packages/http-client-python/generator/test/azure/mock_api_tests/test_resiliency_srv_driven_async.py index 14f3163273..290e3b68cb 100644 --- a/packages/http-client-python/generator/test/azure/mock_api_tests/test_resiliency_srv_driven_async.py +++ b/packages/http-client-python/generator/test/azure/mock_api_tests/test_resiliency_srv_driven_async.py @@ -96,6 +96,7 @@ async def test_add_optional_param_from_one_optional(): @pytest.mark.asyncio async def test_break_the_glass(): from azure.core.rest import HttpRequest + request = HttpRequest(method="DELETE", url="/add-operation") async with V1Client( endpoint="http://localhost:3000", diff --git a/packages/http-client-python/micropip.lock b/packages/http-client-python/micropip.lock new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/http-client-python/package.json b/packages/http-client-python/package.json index 934fcae1bf..83a6986676 100644 --- a/packages/http-client-python/package.json +++ b/packages/http-client-python/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/http-client-python", - "version": "0.5.1", + "version": "0.5.2", "author": "Microsoft Corporation", "description": "TypeSpec emitter for Python SDKs", "homepage": "https://typespec.io", From 19adaa281881330dab32baf2fed5e04bc420bbd6 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 8 Jan 2025 17:05:20 -0500 Subject: [PATCH 3/6] ignore micropip.lock --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 34ebbd74af..c00a162959 100644 --- a/.gitignore +++ b/.gitignore @@ -225,3 +225,4 @@ BenchmarkDotnet.Artifacts/ packages/http-client-python/generator/test/**/generated/ packages/http-client-python/generator/test/**/cadl-ranch-coverage.json !packages/http-client-python/package-lock.json +packages/http-client-python/micropip.lock From 78061c1e7720df85ccd43876b0836bf0ed860689 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Wed, 8 Jan 2025 17:05:44 -0500 Subject: [PATCH 4/6] remove micropip from commit --- packages/http-client-python/micropip.lock | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 packages/http-client-python/micropip.lock diff --git a/packages/http-client-python/micropip.lock b/packages/http-client-python/micropip.lock deleted file mode 100644 index e69de29bb2..0000000000 From ee4ea9cb9f0c5e4e1978c01019f0b04791741e9b Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Thu, 9 Jan 2025 12:16:38 -0500 Subject: [PATCH 5/6] fix spacing --- .../generator/pygen/codegen/models/model_type.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/http-client-python/generator/pygen/codegen/models/model_type.py b/packages/http-client-python/generator/pygen/codegen/models/model_type.py index 9784bc7a5a..85df76fdf4 100644 --- a/packages/http-client-python/generator/pygen/codegen/models/model_type.py +++ b/packages/http-client-python/generator/pygen/codegen/models/model_type.py @@ -347,7 +347,8 @@ def instance_check_template(self) -> str: def imports(self, **kwargs: Any) -> FileImport: file_import = super().imports(**kwargs) - file_import.add_submodule_import("typing", "Any", ImportType.STDLIB, TypingSection.CONDITIONAL) + if self.flattened_property: + file_import.add_submodule_import("typing", "Any", ImportType.STDLIB, TypingSection.CONDITIONAL) return file_import @@ -367,6 +368,5 @@ def instance_check_template(self) -> str: def imports(self, **kwargs: Any) -> FileImport: file_import = super().imports(**kwargs) - if self.flattened_property: - file_import.add_submodule_import("typing", "Any", ImportType.STDLIB) + file_import.add_submodule_import("typing", "Any", ImportType.STDLIB) return file_import From 3c5163526cb5e8ca8ec4a126bd3f28dd6043f387 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Thu, 9 Jan 2025 15:28:29 -0500 Subject: [PATCH 6/6] revert accidental commit --- .../generator/pygen/codegen/models/model_type.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/http-client-python/generator/pygen/codegen/models/model_type.py b/packages/http-client-python/generator/pygen/codegen/models/model_type.py index 85df76fdf4..9784bc7a5a 100644 --- a/packages/http-client-python/generator/pygen/codegen/models/model_type.py +++ b/packages/http-client-python/generator/pygen/codegen/models/model_type.py @@ -347,8 +347,7 @@ def instance_check_template(self) -> str: def imports(self, **kwargs: Any) -> FileImport: file_import = super().imports(**kwargs) - if self.flattened_property: - file_import.add_submodule_import("typing", "Any", ImportType.STDLIB, TypingSection.CONDITIONAL) + file_import.add_submodule_import("typing", "Any", ImportType.STDLIB, TypingSection.CONDITIONAL) return file_import @@ -368,5 +367,6 @@ def instance_check_template(self) -> str: def imports(self, **kwargs: Any) -> FileImport: file_import = super().imports(**kwargs) - file_import.add_submodule_import("typing", "Any", ImportType.STDLIB) + if self.flattened_property: + file_import.add_submodule_import("typing", "Any", ImportType.STDLIB) return file_import