Skip to content

Commit 89f1e33

Browse files
committed
fix circle import issue
1 parent 27f46d1 commit 89f1e33

File tree

7 files changed

+29
-24
lines changed

7 files changed

+29
-24
lines changed

sdk/cognitivelanguage/azure-ai-language-questionanswering-authoring/azure/ai/language/questionanswering/authoring/_operations/_patch.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@
88
99
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
1010
"""
11+
from __future__ import annotations
1112

12-
from typing import Any, Union, overload
13+
from typing import Any, Union, overload, IO, Any, TYPE_CHECKING
1314
from azure.core.polling import LROPoller
1415
from azure.core.tracing.decorator import distributed_trace
15-
from . import _models
16+
17+
# Import specific model types only for static type checking to avoid runtime circular imports.
18+
if TYPE_CHECKING:
19+
from ..models import _models
20+
1621
from ._operations import (
1722
_QuestionAnsweringAuthoringClientOperationsMixin as _QuestionAnsweringAuthoringClientOperationsMixinGenerated,
1823
)
19-
from typing_extensions import JSON, IO
2024

2125

2226
class _QuestionAnsweringAuthoringClientOperationsMixin(_QuestionAnsweringAuthoringClientOperationsMixinGenerated):

sdk/cognitivelanguage/azure-ai-language-questionanswering-authoring/azure/ai/language/questionanswering/authoring/aio/_operations/_patch.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
1010
"""
1111

12-
from typing import Any, Union, overload
12+
from __future__ import annotations
13+
from typing import Any, Union, overload, IO, Any, TYPE_CHECKING
1314
from azure.core.polling import AsyncLROPoller
1415
from azure.core.tracing.decorator_async import distributed_trace_async
15-
from . import _models
16+
if TYPE_CHECKING:
17+
from . import _models
1618
from ._operations import (
1719
_QuestionAnsweringAuthoringClientOperationsMixin as _QuestionAnsweringAuthoringClientOperationsMixinGenerated,
1820
)
19-
from typing_extensions import JSON, IO
2021

2122

2223
class _QuestionAnsweringAuthoringClientOperationsMixin(_QuestionAnsweringAuthoringClientOperationsMixinGenerated):

sdk/cognitivelanguage/azure-ai-language-questionanswering-authoring/tests/helpers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def create_test_project(
1515
polling_interval = kwargs.pop("polling_interval", None)
1616
client.create_project(
1717
project_name=project_name,
18-
body={
18+
options={
1919
"description": "Biography of Sir Isaac Newton",
2020
"language": "en",
2121
"multilingualResource": True,
@@ -34,7 +34,7 @@ def create_test_project(
3434
def add_sources(client, project_name, **kwargs):
3535
poller = client.begin_update_sources(
3636
project_name=project_name,
37-
body=[
37+
sources=[
3838
{
3939
"op": "add",
4040
"value": {
@@ -77,7 +77,7 @@ async def create_test_project(
7777
polling_interval = kwargs.pop("polling_interval", None)
7878
await client.create_project(
7979
project_name=project_name,
80-
body={
80+
options={
8181
"description": "Biography of Sir Isaac Newton",
8282
"language": "en",
8383
"multilingualResource": True,
@@ -96,7 +96,7 @@ async def create_test_project(
9696
async def add_sources(client, project_name, **kwargs):
9797
poller = await client.begin_update_sources(
9898
project_name=project_name,
99-
body=[
99+
sources=[
100100
{
101101
"op": "add",
102102
"value": {

sdk/cognitivelanguage/azure-ai-language-questionanswering-authoring/tests/test_create_and_deploy_project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_create_project(self, recorded_test, qna_authoring_creds): # type: igno
2727
project_name = "IsaacNewton"
2828
client.create_project(
2929
project_name=project_name,
30-
body={
30+
options={
3131
"description": "Biography of Sir Isaac Newton",
3232
"language": "en",
3333
"multilingualResource": True,

sdk/cognitivelanguage/azure-ai-language-questionanswering-authoring/tests/test_create_and_deploy_project_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async def test_create_project(self, recorded_test, qna_authoring_creds): # type
1717
async with client:
1818
await client.create_project(
1919
project_name=project_name,
20-
body={
20+
options={
2121
"description": "Biography of Sir Isaac Newton",
2222
"language": "en",
2323
"multilingualResource": True,

sdk/cognitivelanguage/azure-ai-language-questionanswering-authoring/tests/test_update_knowledge_sources.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ def test_add_source(self, recorded_test, qna_authoring_creds): # type: ignore[n
3232
]
3333
poller = client.begin_update_sources(
3434
project_name=project_name,
35-
body=cast(list[_models.UpdateSourceRecord], update_source_ops),
35+
sources=cast(list[_models.UpdateSourceRecord], update_source_ops),
3636
content_type="application/json",
3737
polling_interval=0 if self.is_playback else None, # type: ignore[arg-type]
3838
)
3939
poller.result()
40-
assert any(s.get("displayName") == source_display_name for s in client.get_sources(project_name=project_name))
40+
assert any(s.get("displayName") == source_display_name for s in client.list_sources(project_name=project_name))
4141

4242
def test_add_qna(self, recorded_test, qna_authoring_creds): # type: ignore[name-defined]
4343
client = QuestionAnsweringAuthoringClient(
@@ -61,14 +61,14 @@ def test_add_qna(self, recorded_test, qna_authoring_creds): # type: ignore[name
6161
]
6262
poller = client.begin_update_qnas(
6363
project_name=project_name,
64-
body=cast(list[_models.UpdateQnaRecord], update_qna_ops),
64+
qnas=cast(list[_models.UpdateQnaRecord], update_qna_ops),
6565
content_type="application/json",
6666
polling_interval=0 if self.is_playback else None, # type: ignore[arg-type]
6767
)
6868
poller.result()
6969
assert any(
7070
(q.get("answer") == answer and question in q.get("questions", []))
71-
for q in client.get_qnas(project_name=project_name)
71+
for q in client.list_qnas(project_name=project_name)
7272
)
7373

7474
def test_add_synonym(self, recorded_test, qna_authoring_creds): # type: ignore[name-defined]
@@ -84,10 +84,10 @@ def test_add_synonym(self, recorded_test, qna_authoring_creds): # type: ignore[
8484
)
8585
client.update_synonyms(
8686
project_name=project_name,
87-
body=synonyms_model,
87+
synonyms=synonyms_model,
8888
content_type="application/json",
8989
)
9090
assert any(
9191
("qnamaker" in s.get("alterations", []) and "qna maker" in s.get("alterations", []))
92-
for s in client.get_synonyms(project_name=project_name)
92+
for s in client.list_synonyms(project_name=project_name)
9393
)

sdk/cognitivelanguage/azure-ai-language-questionanswering-authoring/tests/test_update_knowledge_sources_async.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ async def test_add_source(self, recorded_test, qna_authoring_creds): # type: ig
3636
]
3737
poller = await client.begin_update_sources(
3838
project_name=project_name,
39-
body=cast(list[_models.UpdateSourceRecord], update_source_ops),
39+
sources=cast(list[_models.UpdateSourceRecord], update_source_ops),
4040
content_type="application/json",
4141
polling_interval=0 if self.is_playback else None, # type: ignore[arg-type]
4242
)
4343
await poller.result()
4444
found = False
45-
async for s in client.get_sources(project_name=project_name):
45+
async for s in client.list_sources(project_name=project_name):
4646
if s.get("displayName") == "MicrosoftFAQ":
4747
found = True
4848
assert found
@@ -73,13 +73,13 @@ async def test_add_qna(self, recorded_test, qna_authoring_creds): # type: ignor
7373
]
7474
poller = await client.begin_update_qnas(
7575
project_name=project_name,
76-
body=cast(list[_models.UpdateQnaRecord], update_qna_ops),
76+
qnas=cast(list[_models.UpdateQnaRecord], update_qna_ops),
7777
content_type="application/json",
7878
polling_interval=0 if self.is_playback else None, # type: ignore[arg-type]
7979
)
8080
await poller.result()
8181
found = False
82-
async for qna in client.get_qnas(project_name=project_name):
82+
async for qna in client.list_qnas(project_name=project_name):
8383
if qna.get("answer") == answer and question in qna.get("questions", []):
8484
found = True
8585
assert found
@@ -101,11 +101,11 @@ async def test_add_synonym(self, recorded_test, qna_authoring_creds): # type: i
101101
)
102102
await client.update_synonyms(
103103
project_name=project_name,
104-
body=synonyms_model,
104+
synonyms=synonyms_model,
105105
content_type="application/json",
106106
)
107107
found = False
108-
async for s in client.get_synonyms(project_name=project_name):
108+
async for s in client.list_synonyms(project_name=project_name):
109109
if "qnamaker" in s.get("alterations", []) and "qna maker" in s.get("alterations", []):
110110
found = True
111111
assert found

0 commit comments

Comments
 (0)