Skip to content
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

[PBE-1321] support campaign endpoints #155

Closed
wants to merge 18 commits into from
Closed

Conversation

kanat
Copy link
Contributor

@kanat kanat commented Feb 10, 2024

Submit a pull request

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested (add some information if not applicable)

Description of the pull request

from typing import Any, Awaitable, Dict, Iterable, List, TypeVar, Union, Optional

from stream_chat.types.campaign import CampaignData, QueryCampaignsOptions
from stream_chat.types.segment import SegmentType, SegmentData, QuerySegmentsOptions, UpdateSegmentData
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
from stream_chat.types.segment import SegmentType, SegmentData, QuerySegmentsOptions, UpdateSegmentData
from stream_chat.types.segment import (
SegmentType,
SegmentData,
QuerySegmentsOptions,
UpdateSegmentData,
)

@@ -920,7 +923,7 @@ def list_roles(self) -> Union[StreamResponse, Awaitable[StreamResponse]]:

@abc.abstractmethod
def create_segment(
self, segment: Dict
self, segment_type: SegmentType, segment_id: str, segment_name: str, data: SegmentData
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
self, segment_type: SegmentType, segment_id: str, segment_name: str, data: SegmentData
self,
segment_type: SegmentType,
segment_id: str,
segment_name: str,
data: SegmentData,

@@ -6,6 +6,9 @@
from urllib.parse import urlparse
from urllib.request import Request, urlopen

from stream_chat.types.campaign import QueryCampaignsOptions, CampaignData
from stream_chat.types.segment import SegmentType, QuerySegmentsOptions, UpdateSegmentData
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
from stream_chat.types.segment import SegmentType, QuerySegmentsOptions, UpdateSegmentData
from stream_chat.types.segment import (
SegmentType,
QuerySegmentsOptions,
UpdateSegmentData,
)

Comment on lines 524 to 527
def create_segment(self, segment_type: SegmentType, segment_id: str, name: str, data: Dict) -> StreamResponse:
return self.post("segments", data={"type": segment_type.value, "id": segment_id, "name": name, "data": data})

def query_segments(self, **params: Any) -> StreamResponse:
return self.get("segments", params={"payload": json.dumps(params)})
def query_segments(self, filter_conditions: Dict, options: QuerySegmentsOptions) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
def create_segment(self, segment_type: SegmentType, segment_id: str, name: str, data: Dict) -> StreamResponse:
return self.post("segments", data={"type": segment_type.value, "id": segment_id, "name": name, "data": data})
def query_segments(self, **params: Any) -> StreamResponse:
return self.get("segments", params={"payload": json.dumps(params)})
def query_segments(self, filter_conditions: Dict, options: QuerySegmentsOptions) -> StreamResponse:
def create_segment(
self, segment_type: SegmentType, segment_id: str, name: str, data: Dict
) -> StreamResponse:
return self.post(
"segments",
data={
"type": segment_type.value,
"id": segment_id,
"name": name,
"data": data,
},
)
def query_segments(
self, filter_conditions: Dict, options: QuerySegmentsOptions
) -> StreamResponse:


def update_segment(self, segment_id: str, data: Dict) -> StreamResponse:
return self.put(f"segments/{segment_id}", data={"segment": data})
def update_segment(self, segment_id: str, data: UpdateSegmentData) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
def update_segment(self, segment_id: str, data: UpdateSegmentData) -> StreamResponse:
def update_segment(
self, segment_id: str, data: UpdateSegmentData
) -> StreamResponse:


async def update_segment(self, segment_id: str, data: Dict) -> StreamResponse:
return await self.put(f"segments/{segment_id}", data={"segment": data})
async def update_segment(self, segment_id: str, data: UpdateSegmentData) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
async def update_segment(self, segment_id: str, data: UpdateSegmentData) -> StreamResponse:
async def update_segment(
self, segment_id: str, data: UpdateSegmentData
) -> StreamResponse:


async def query_campaigns(self, **params: Any) -> StreamResponse:
return await self.get("campaigns", params={"payload": json.dumps(params)})
async def query_campaigns(self, filter_conditions: Dict[str, Any], options: QueryCampaignsOptions = None) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
async def query_campaigns(self, filter_conditions: Dict[str, Any], options: QueryCampaignsOptions = None) -> StreamResponse:
async def query_campaigns(
self, filter_conditions: Dict[str, Any], options: QueryCampaignsOptions = None
) -> StreamResponse:


async def update_campaign(self, campaign_id: str, data: Dict) -> StreamResponse:
return await self.put(f"campaigns/{campaign_id}", data={"campaign": data})
async def update_campaign(self, campaign_id: str, params: CampaignData) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
async def update_campaign(self, campaign_id: str, params: CampaignData) -> StreamResponse:
async def update_campaign(
self, campaign_id: str, params: CampaignData
) -> StreamResponse:

Comment on lines 24 to 26



Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change

Comment on lines 25 to 29





Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change

@@ -16,6 +16,9 @@
)
from urllib.parse import urlparse

from stream_chat.types.campaign import CampaignData, QueryCampaignsOptions
from stream_chat.types.segment import SegmentType, SegmentData, QuerySegmentsOptions, UpdateSegmentData
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position

@@ -16,6 +16,9 @@
)
from urllib.parse import urlparse

from stream_chat.types.campaign import CampaignData, QueryCampaignsOptions
from stream_chat.types.segment import SegmentType, SegmentData, QuerySegmentsOptions, UpdateSegmentData

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <5> reported by reviewdog 🐶
isort found an unexpected missing import

@@ -16,6 +16,9 @@
)
from urllib.parse import urlparse

from stream_chat.types.campaign import CampaignData, QueryCampaignsOptions
from stream_chat.types.segment import SegmentType, SegmentData, QuerySegmentsOptions, UpdateSegmentData

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <5> reported by reviewdog 🐶
isort found an unexpected missing import

@@ -16,6 +16,9 @@
)
from urllib.parse import urlparse

from stream_chat.types.campaign import CampaignData, QueryCampaignsOptions
from stream_chat.types.segment import SegmentType, SegmentData, QuerySegmentsOptions, UpdateSegmentData

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <5> reported by reviewdog 🐶
isort found an unexpected missing import

@@ -16,6 +16,9 @@
)
from urllib.parse import urlparse

from stream_chat.types.campaign import CampaignData, QueryCampaignsOptions
from stream_chat.types.segment import SegmentType, SegmentData, QuerySegmentsOptions, UpdateSegmentData

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <5> reported by reviewdog 🐶
isort found an unexpected missing import

@@ -0,0 +1,29 @@
from typing import List, Optional, TypedDict, Dict
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position

@@ -0,0 +1,29 @@
from typing import List, Optional, TypedDict, Dict

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <5> reported by reviewdog 🐶
isort found an unexpected missing import





Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [flake8] <391> reported by reviewdog 🐶
blank line at end of file

@@ -0,0 +1,22 @@
from enum import Enum
from typing import TypedDict, Optional, Dict, List
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position

@@ -0,0 +1,22 @@
from enum import Enum
from typing import TypedDict, Optional, Dict, List

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <5> reported by reviewdog 🐶
isort found an unexpected missing import

@@ -518,26 +521,28 @@ def delete_role(self, name: str) -> StreamResponse:
def list_roles(self) -> StreamResponse:
return self.get("roles")

def create_segment(self, segment: Dict) -> StreamResponse:
return self.post("segments", data={"segment": segment})
def create_segment(self, segment_type: SegmentType, segment_id: str, name: str, data: Dict) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Argument 4 of "create_segment" is incompatible with supertype "StreamChatInterface"; supertype defines the argument type as "SegmentData" [override]

@@ -518,26 +521,28 @@ def delete_role(self, name: str) -> StreamResponse:
def list_roles(self) -> StreamResponse:
return self.get("roles")

def create_segment(self, segment: Dict) -> StreamResponse:
return self.post("segments", data={"segment": segment})
def create_segment(self, segment_type: SegmentType, segment_id: str, name: str, data: Dict) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
This violates the Liskov substitution principle

@@ -518,26 +521,28 @@ def delete_role(self, name: str) -> StreamResponse:
def list_roles(self) -> StreamResponse:
return self.get("roles")

def create_segment(self, segment: Dict) -> StreamResponse:
return self.post("segments", data={"segment": segment})
def create_segment(self, segment_type: SegmentType, segment_id: str, name: str, data: Dict) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass

@abc.abstractmethod
def update(self, data: UpdateSegmentData) -> Union[StreamResponse, Awaitable[StreamResponse]]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
def update(self, data: UpdateSegmentData) -> Union[StreamResponse, Awaitable[StreamResponse]]:
def update(
self, data: UpdateSegmentData
) -> Union[StreamResponse, Awaitable[StreamResponse]]:

class Campaign(CampaignInterface):

def create(self) -> StreamResponse:
state = self.client.create_campaign(campaign_id=self.campaign_id, data=self.data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
state = self.client.create_campaign(campaign_id=self.campaign_id, data=self.data)
state = self.client.create_campaign(
campaign_id=self.campaign_id, data=self.data
)

segment_type=self.segment_type,
segment_id=self.segment_id,
segment_name=self.segment_name,
data=self.data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
data=self.data
data=self.data,

},
options={
"limit": 1,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
}
},

Comment on lines 36 to 39
return self.client.update_segment(
segment_id=self.segment_id,
data=data
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
return self.client.update_segment(
segment_id=self.segment_id,
data=data
)
return self.client.update_segment(segment_id=self.segment_id, data=data)


def delete_segment(self, segment_id: str) -> StreamResponse:
return self.delete(f"segments/{segment_id}")

def create_campaign(self, campaign: Dict) -> StreamResponse:
return self.post("campaigns", data={"campaign": campaign})
def campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> Campaign:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
def campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> Campaign:
def campaign(
self, campaign_id: Optional[str] = None, data: CampaignData = None
) -> Campaign:

def campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> Campaign:
return Campaign(client=self, campaign_id=campaign_id, data=data)

def create_campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
def create_campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> StreamResponse:
def create_campaign(
self, campaign_id: Optional[str] = None, data: CampaignData = None
) -> StreamResponse:

Comment on lines 557 to 558
def query_campaigns(self, filter_conditions: Dict[str, Any],
options: QueryCampaignsOptions = None) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
def query_campaigns(self, filter_conditions: Dict[str, Any],
options: QueryCampaignsOptions = None) -> StreamResponse:
def query_campaigns(
self, filter_conditions: Dict[str, Any], options: QueryCampaignsOptions = None
) -> StreamResponse:

def schedule_campaign(
self, campaign_id: str, scheduled_for: int = None
def start_campaign(
self, campaign_id: str, scheduled_for: Optional[datetime.datetime] = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
self, campaign_id: str, scheduled_for: Optional[datetime.datetime] = None
self, campaign_id: str, scheduled_for: Optional[datetime.datetime] = None

@@ -65,3 +65,7 @@ def headers(self) -> Dict[str, Any]:
def status_code(self) -> int:
"""Returns the HTTP status code of the response."""
return self.__status_code

def is_ok(self) -> bool:
"""Returns True if the status code is in the 200 range. """
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
"""Returns True if the status code is in the 200 range. """
"""Returns True if the status code is in the 200 range."""

@@ -0,0 +1,42 @@
import abc
from typing import Awaitable, Dict, List, Union, Optional
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position

@@ -0,0 +1,42 @@
import abc
from typing import Awaitable, Dict, List, Union, Optional
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[flake8] <401> reported by reviewdog 🐶
'typing.Dict' imported but unused

@@ -0,0 +1,42 @@
import abc
from typing import Awaitable, Dict, List, Union, Optional
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[flake8] <401> reported by reviewdog 🐶
'typing.List' imported but unused

@@ -0,0 +1,42 @@
import abc
from typing import Awaitable, Dict, List, Union, Optional

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <5> reported by reviewdog 🐶
isort found an unexpected missing import

@@ -918,9 +924,20 @@ def list_roles(self) -> Union[StreamResponse, Awaitable[StreamResponse]]:
"""
pass

def segment(self, segment_type: SegmentType, segment_id: str, segment_name: str) -> TSegment:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[flake8] <27> reported by reviewdog 🐶
segment is an empty method in an abstract base class, but has no abstract decorator. Consider adding @AbstractMethod.


from stream_chat.base.client import StreamChatInterface
from stream_chat.types.segment import SegmentType, SegmentData, UpdateSegmentData
from stream_chat.types.stream_response import StreamResponse
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <5> reported by reviewdog 🐶
isort found an unexpected missing import

@@ -2,16 +2,20 @@
import json
import sys
import warnings
from typing import Any, Callable, Dict, Iterable, List, Union
from typing import Any, Callable, Dict, Iterable, List, Union, Optional
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position

from stream_chat.campaign import Campaign
from stream_chat.segment import Segment
from stream_chat.types.campaign import QueryCampaignsOptions, CampaignData
from stream_chat.types.segment import SegmentType, QuerySegmentsOptions, UpdateSegmentData, SegmentData
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position

assert "name" in created["campaign"]

client.delete_segment(segment_id=segment_id)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [flake8] <391> reported by reviewdog 🐶
blank line at end of file


deleted = segment.delete()
assert deleted.is_ok()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [flake8] <391> reported by reviewdog 🐶
blank line at end of file

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

mypy

stream_chat/client.py|551 col 28| Expected:
stream_chat/client.py|551 col 28| def getitem(self, str, /) -> str
stream_chat/client.py|551 col 28| Got:
stream_chat/client.py|551 col 28| def getitem(self, str, /) -> object
stream_chat/async_chat/client.py|556 col 5| Signature of "create_campaign" incompatible with supertype "StreamChatInterface" [override]
stream_chat/async_chat/client.py|556 col 5| Superclass:
stream_chat/async_chat/client.py|556 col 5| def create_campaign(self, campaign_id: str | None, data: CampaignData | None) -> StreamResponse | Awaitable[StreamResponse]
stream_chat/async_chat/client.py|556 col 5| Subclass:
stream_chat/async_chat/client.py|556 col 5| def create_campaign(self, params: CampaignData) -> Coroutine[Any, Any, StreamResponse]

@@ -918,9 +924,20 @@ def list_roles(self) -> Union[StreamResponse, Awaitable[StreamResponse]]:
"""
pass

def segment(self, segment_type: SegmentType, segment_id: str, segment_name: str) -> TSegment:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var]

@@ -954,9 +971,28 @@
"""
pass

def campaign(self, campaign_id: Optional[str]):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Function is missing a return type annotation [no-untyped-def]

data=self.data
)

if self.segment_id is None and state.is_ok() and "segment" in state:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Item "Awaitable[StreamResponse]" of "StreamResponse | Awaitable[StreamResponse]" has no attribute "is_ok" [union-attr]

data=self.data
)

if self.segment_id is None and state.is_ok() and "segment" in state:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
Maybe you forgot to use "await"?

data=self.data
)

if self.segment_id is None and state.is_ok() and "segment" in state:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Unsupported right operand type for in ("StreamResponse | Awaitable[StreamResponse]") [operator]

return Segment(client=self, segment_type=segment_type, segment_id=segment_id, segment_name=segment_name,
data=data)

def create_segment(self, segment_type: SegmentType, segment_id: Optional[str] = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
def create_segment(self, segment_type: SegmentType, segment_id: str, segment_name: str, data: SegmentData) -> StreamResponse | Awaitable[StreamResponse]

return Segment(client=self, segment_type=segment_type, segment_id=segment_id, segment_name=segment_name,
data=data)

def create_segment(self, segment_type: SegmentType, segment_id: Optional[str] = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
Subclass:

return Segment(client=self, segment_type=segment_type, segment_id=segment_id, segment_name=segment_name,
data=data)

def create_segment(self, segment_type: SegmentType, segment_id: Optional[str] = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
def create_segment(self, segment_type: SegmentType, segment_id: str | None = ..., segment_name: str | None = ..., data: dict[Any, Any] = ...) -> StreamResponse

def create_campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> StreamResponse:
payload = {"id": campaign_id}
if data is not None:
payload.update(data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Argument 1 to "update" of "MutableMapping" has incompatible type "CampaignData"; expected "SupportsKeysAndGetItem[str, str]" [arg-type]

def create_campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> StreamResponse:
payload = {"id": campaign_id}
if data is not None:
payload.update(data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
Following member(s) of "CampaignData" have conflicts:

pass

@abc.abstractmethod
def update(self, data: CampaignData) -> Union[StreamResponse, Awaitable[StreamResponse]]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
def update(self, data: CampaignData) -> Union[StreamResponse, Awaitable[StreamResponse]]:
def update(
self, data: CampaignData
) -> Union[StreamResponse, Awaitable[StreamResponse]]:

pass

@abc.abstractmethod
def start(self, scheduled_for: Optional[Union[str, datetime.datetime]] = None) -> Union[StreamResponse, Awaitable[StreamResponse]]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
def start(self, scheduled_for: Optional[Union[str, datetime.datetime]] = None) -> Union[StreamResponse, Awaitable[StreamResponse]]:
def start(
self, scheduled_for: Optional[Union[str, datetime.datetime]] = None
) -> Union[StreamResponse, Awaitable[StreamResponse]]:

return self.client.update_campaign(campaign_id=self.campaign_id, data=data)

def delete(self, **options: Any) -> StreamResponse:
return self.client.delete_campaign(campaign_id=self.campaign_id, options=options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
return self.client.delete_campaign(campaign_id=self.campaign_id, options=options)
return self.client.delete_campaign(
campaign_id=self.campaign_id, options=options
)

Comment on lines 27 to 28
def start(self, scheduled_for: Optional[Union[str, datetime.datetime]] = None) -> StreamResponse:
return self.client.start_campaign(campaign_id=self.campaign_id, scheduled_for=scheduled_for)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
def start(self, scheduled_for: Optional[Union[str, datetime.datetime]] = None) -> StreamResponse:
return self.client.start_campaign(campaign_id=self.campaign_id, scheduled_for=scheduled_for)
def start(
self, scheduled_for: Optional[Union[str, datetime.datetime]] = None
) -> StreamResponse:
return self.client.start_campaign(
campaign_id=self.campaign_id, scheduled_for=scheduled_for
)

pass

@abc.abstractmethod
def update(self, data: SegmentData) -> Union[StreamResponse, Awaitable[StreamResponse]]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
def update(self, data: SegmentData) -> Union[StreamResponse, Awaitable[StreamResponse]]:
def update(
self, data: SegmentData
) -> Union[StreamResponse, Awaitable[StreamResponse]]:

Comment on lines 549 to 551
def segment_target_exists(
self, segment_id: str, target_id: str
) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
def segment_target_exists(
self, segment_id: str, target_id: str
) -> StreamResponse:
def segment_target_exists(self, segment_id: str, target_id: str) -> StreamResponse:

def add_segment_targets(
self, segment_id: str, target_ids: List[str]
) -> StreamResponse:
return self.post(f"segments/{segment_id}/addtargets", data={"targets": target_ids})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
return self.post(f"segments/{segment_id}/addtargets", data={"targets": target_ids})
return self.post(
f"segments/{segment_id}/addtargets", data={"targets": target_ids}
)

Comment on lines 562 to 564
return self.post(f"segments/{segment_id}/deletetargets", data={"targets": target_ids})

def campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> Campaign:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
return self.post(f"segments/{segment_id}/deletetargets", data={"targets": target_ids})
def campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> Campaign:
return self.post(
f"segments/{segment_id}/deletetargets", data={"targets": target_ids}
)
def campaign(
self, campaign_id: Optional[str] = None, data: CampaignData = None
) -> Campaign:

def schedule_campaign(
self, campaign_id: str, scheduled_for: int = None
def start_campaign(
self, campaign_id: str, scheduled_for: Optional[Union[str, datetime.datetime]] = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
self, campaign_id: str, scheduled_for: Optional[Union[str, datetime.datetime]] = None
self,
campaign_id: str,
scheduled_for: Optional[Union[str, datetime.datetime]] = None,

Comment on lines 595 to 597
return self.post(
f"campaigns/{campaign_id}/start", data=payload
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
return self.post(
f"campaigns/{campaign_id}/start", data=payload
)
return self.post(f"campaigns/{campaign_id}/start", data=payload)

@@ -16,6 +16,9 @@
)
from urllib.parse import urlparse

from stream_chat.types.campaign import CampaignData, QueryCampaignsOptions
from stream_chat.types.segment import SegmentType, SegmentData, QuerySegmentsOptions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position

from typing import Any, Awaitable, Dict, Iterable, List, TypeVar, Union, Optional

from stream_chat.types.campaign import CampaignData, QueryCampaignsOptions
from stream_chat.types.segment import SegmentType, SegmentData, QuerySegmentsOptions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position

@@ -918,18 +924,38 @@ def list_roles(self) -> Union[StreamResponse, Awaitable[StreamResponse]]:
"""
pass

def segment(self, segment_type: SegmentType, data: Optional[SegmentData]) -> TSegment:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[flake8] <27> reported by reviewdog 🐶
segment is an empty method in an abstract base class, but has no abstract decorator. Consider adding @AbstractMethod.

@@ -0,0 +1,48 @@
import abc
from typing import Optional, Awaitable, Union, List
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position

from typing import Optional, Awaitable, Union, List

from stream_chat.base.client import StreamChatInterface
from stream_chat.types.segment import SegmentType, SegmentData
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position

from stream_chat.campaign import Campaign
from stream_chat.segment import Segment
from stream_chat.types.campaign import QueryCampaignsOptions, CampaignData
from stream_chat.types.segment import SegmentType, QuerySegmentsOptions, SegmentData
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position

def segment(self, segment_type: SegmentType, segment_id: Optional[str] = None, data: Optional[SegmentData] = None) -> Segment:
return Segment(client=self, segment_type=segment_type, segment_id=segment_id, data=data)

def create_segment(self, segment_type: SegmentType, segment_id: Optional[str]=None, data: Optional[SegmentData] = None) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [flake8] <252> reported by reviewdog 🐶
missing whitespace around parameter equals

def segment(self, segment_type: SegmentType, segment_id: Optional[str] = None, data: Optional[SegmentData] = None) -> Segment:
return Segment(client=self, segment_type=segment_type, segment_id=segment_id, data=data)

def create_segment(self, segment_type: SegmentType, segment_id: Optional[str]=None, data: Optional[SegmentData] = None) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [flake8] <252> reported by reviewdog 🐶
missing whitespace around parameter equals


deleted = segment.delete()
assert deleted.is_ok()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [flake8] <391> reported by reviewdog 🐶
blank line at end of file

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

mypy

stream_chat/async_chat/client.py|556 col 5| Superclass:
stream_chat/async_chat/client.py|556 col 5| def create_campaign(self, campaign_id: str | None, data: CampaignData | None) -> StreamResponse | Awaitable[StreamResponse]
stream_chat/async_chat/client.py|556 col 5| Subclass:
stream_chat/async_chat/client.py|556 col 5| def create_campaign(self, params: CampaignData) -> Coroutine[Any, Any, StreamResponse]

@@ -918,18 +924,38 @@ def list_roles(self) -> Union[StreamResponse, Awaitable[StreamResponse]]:
"""
pass

def segment(self, segment_type: SegmentType, data: Optional[SegmentData]) -> TSegment:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var]

return state

def get(self) -> StreamResponse:
return self.client.get_segment(segment_id=self.segment_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible return value type (got "StreamResponse | Awaitable[StreamResponse]", expected "StreamResponse") [return-value]

return self.client.delete_segment(segment_id=self.segment_id)

def target_exists(self, target_id: str) -> StreamResponse:
return self.client.segment_target_exists(segment_id=self.segment_id, target_id=target_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible return value type (got "StreamResponse | Awaitable[StreamResponse]", expected "StreamResponse") [return-value]

return self.client.segment_target_exists(segment_id=self.segment_id, target_id=target_id)

def add_targets(self, target_ids: list) -> StreamResponse:
return self.client.add_segment_targets(segment_id=self.segment_id, target_ids=target_ids)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible return value type (got "StreamResponse | Awaitable[StreamResponse]", expected "StreamResponse") [return-value]

return self.client.add_segment_targets(segment_id=self.segment_id, target_ids=target_ids)

def delete_targets(self, target_ids: list) -> StreamResponse:
return self.client.delete_segment_targets(segment_id=self.segment_id, target_ids=target_ids)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible return value type (got "StreamResponse | Awaitable[StreamResponse]", expected "StreamResponse") [return-value]

@@ -537,35 +540,37 @@
async def list_roles(self) -> StreamResponse:
return await self.get("roles")

async def create_segment(self, segment: Dict) -> StreamResponse:
return await self.post("segments", data={"segment": segment})
async def create_segment(self, segment_type: SegmentType, segment_id: str, segment_name: str, data: SegmentData) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
Superclass:

@@ -537,35 +540,37 @@
async def list_roles(self) -> StreamResponse:
return await self.get("roles")

async def create_segment(self, segment: Dict) -> StreamResponse:
return await self.post("segments", data={"segment": segment})
async def create_segment(self, segment_type: SegmentType, segment_id: str, segment_name: str, data: SegmentData) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
def create_segment(self, segment_type: SegmentType, segment_id: str | None, data: SegmentData | None = ...) -> StreamResponse | Awaitable[StreamResponse]

@@ -537,35 +540,37 @@
async def list_roles(self) -> StreamResponse:
return await self.get("roles")

async def create_segment(self, segment: Dict) -> StreamResponse:
return await self.post("segments", data={"segment": segment})
async def create_segment(self, segment_type: SegmentType, segment_id: str, segment_name: str, data: SegmentData) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
Subclass:

@@ -537,35 +540,37 @@
async def list_roles(self) -> StreamResponse:
return await self.get("roles")

async def create_segment(self, segment: Dict) -> StreamResponse:
return await self.post("segments", data={"segment": segment})
async def create_segment(self, segment_type: SegmentType, segment_id: str, segment_name: str, data: SegmentData) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
def create_segment(self, segment_type: SegmentType, segment_id: str, segment_name: str, data: SegmentData) -> Coroutine[Any, Any, StreamResponse]


async def delete_segment(self, segment_id: str) -> StreamResponse:
return await self.delete(f"segments/{segment_id}")

async def create_campaign(self, campaign: Dict) -> StreamResponse:
return await self.post("campaigns", data={"campaign": campaign})
async def create_campaign(self, params: CampaignData) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Signature of "create_campaign" incompatible with supertype "StreamChatInterface" [override]

class Campaign(CampaignInterface):

async def create(self) -> StreamResponse:
state = await self.client.create_campaign(campaign_id=self.campaign_id, data=self.data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
state = await self.client.create_campaign(campaign_id=self.campaign_id, data=self.data)
state = await self.client.create_campaign(
campaign_id=self.campaign_id, data=self.data
)

return await self.client.get_campaign(campaign_id=self.campaign_id)

async def update(self, data: CampaignData) -> StreamResponse:
return await self.client.update_campaign(campaign_id=self.campaign_id, data=data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
return await self.client.update_campaign(campaign_id=self.campaign_id, data=data)
return await self.client.update_campaign(
campaign_id=self.campaign_id, data=data
)

return await self.client.update_campaign(campaign_id=self.campaign_id, data=data)

async def delete(self, **options: Any) -> StreamResponse:
return await self.client.delete_campaign(campaign_id=self.campaign_id, options=options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
return await self.client.delete_campaign(campaign_id=self.campaign_id, options=options)
return await self.client.delete_campaign(
campaign_id=self.campaign_id, options=options
)

Comment on lines 27 to 28
async def start(self, scheduled_for: Optional[Union[str, datetime.datetime]] = None) -> StreamResponse:
return await self.client.start_campaign(campaign_id=self.campaign_id, scheduled_for=scheduled_for)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
async def start(self, scheduled_for: Optional[Union[str, datetime.datetime]] = None) -> StreamResponse:
return await self.client.start_campaign(campaign_id=self.campaign_id, scheduled_for=scheduled_for)
async def start(
self, scheduled_for: Optional[Union[str, datetime.datetime]] = None
) -> StreamResponse:
return await self.client.start_campaign(
campaign_id=self.campaign_id, scheduled_for=scheduled_for
)

Comment on lines 10 to 12
segment_type=self.segment_type,
segment_id=self.segment_id,
data=self.data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
segment_type=self.segment_type,
segment_id=self.segment_id,
data=self.data
segment_type=self.segment_type, segment_id=self.segment_id, data=self.data


async def update_campaign(self, campaign_id: str, data: Dict) -> StreamResponse:
return await self.put(f"campaigns/{campaign_id}", data={"campaign": data})
async def update_campaign(self, campaign_id: str, data: CampaignData) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
async def update_campaign(self, campaign_id: str, data: CampaignData) -> StreamResponse:
async def update_campaign(
self, campaign_id: str, data: CampaignData
) -> StreamResponse:

async def schedule_campaign(
self, campaign_id: str, scheduled_for: int = None
async def start_campaign(
self, campaign_id: str, scheduled_for: Optional[Union[str, datetime.datetime]] = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
self, campaign_id: str, scheduled_for: Optional[Union[str, datetime.datetime]] = None
self,
campaign_id: str,
scheduled_for: Optional[Union[str, datetime.datetime]] = None,

Comment on lines 617 to 619
return await self.post(
f"campaigns/{campaign_id}/start", data=payload
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
return await self.post(
f"campaigns/{campaign_id}/start", data=payload
)
return await self.post(f"campaigns/{campaign_id}/start", data=payload)

Comment on lines 26 to 28
updated = await segment.update({
"name": "updated_name"
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
updated = await segment.update({
"name": "updated_name"
})
updated = await segment.update({"name": "updated_name"})


deleted = await segment.delete()
assert deleted.is_ok()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change

async def create_segment(self, segment: Dict) -> StreamResponse:
return await self.post("segments", data={"segment": segment})
def segment(self, segment_type: SegmentType, segment_id: Optional[str] = None,
data: Optional[SegmentData] = None) -> Segment:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [flake8] <127> reported by reviewdog 🐶
continuation line over-indented for visual indent

return Segment(client=self, segment_type=segment_type, segment_id=segment_id, data=data)

async def create_segment(self, segment_type: SegmentType, segment_id: Optional[str] = None,
data: Optional[SegmentData] = None) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [flake8] <128> reported by reviewdog 🐶
continuation line under-indented for visual indent

async def query_campaigns(self, **params: Any) -> StreamResponse:
return await self.get("campaigns", params={"payload": json.dumps(params)})
async def query_campaigns(self, filter_conditions: Dict[str, Any],
options: QueryCampaignsOptions = None) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [flake8] <128> reported by reviewdog 🐶
continuation line under-indented for visual indent

@@ -0,0 +1,43 @@
import abc
import datetime
from typing import Awaitable, Union, Optional
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position


deleted = await segment.delete()
assert deleted.is_ok()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [flake8] <391> reported by reviewdog 🐶
blank line at end of file

class Segment(SegmentInterface):

async def create(self) -> StreamResponse:
state = await self.client.create_segment(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible types in "await" (actual type "StreamResponse | Awaitable[StreamResponse]", expected type "Awaitable[Any]") [misc]

return state

async def get(self) -> StreamResponse:
return await self.client.get_segment(segment_id=self.segment_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible types in "await" (actual type "StreamResponse | Awaitable[StreamResponse]", expected type "Awaitable[Any]") [misc]

return await self.client.get_segment(segment_id=self.segment_id)

async def update(self, data: SegmentData) -> StreamResponse:
return await self.client.update_segment(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible types in "await" (actual type "StreamResponse | Awaitable[StreamResponse]", expected type "Awaitable[Any]") [misc]

)

async def delete(self) -> StreamResponse:
return await self.client.delete_segment(segment_id=self.segment_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible types in "await" (actual type "StreamResponse | Awaitable[StreamResponse]", expected type "Awaitable[Any]") [misc]

return await self.client.delete_segment(segment_id=self.segment_id)

async def target_exists(self, target_id: str) -> StreamResponse:
return await self.client.segment_target_exists(segment_id=self.segment_id, target_id=target_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible types in "await" (actual type "StreamResponse | Awaitable[StreamResponse]", expected type "Awaitable[Any]") [misc]

async def create_campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> StreamResponse:
payload = {"id": campaign_id}
if data is not None:
payload.update(data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
Following member(s) of "CampaignData" have conflicts:

async def create_campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> StreamResponse:
payload = {"id": campaign_id}
if data is not None:
payload.update(data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
Expected:

async def create_campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> StreamResponse:
payload = {"id": campaign_id}
if data is not None:
payload.update(data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
def getitem(self, str, /) -> str

async def create_campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> StreamResponse:
payload = {"id": campaign_id}
if data is not None:
payload.update(data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
Got:

async def create_campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> StreamResponse:
payload = {"id": campaign_id}
if data is not None:
payload.update(data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
def getitem(self, str, /) -> object

@kanat kanat marked this pull request as ready for review February 14, 2024 04:27
@kanat kanat requested a review from gumuz as a code owner February 14, 2024 04:27
Comment on lines 577 to 579
self, segment_id: str, target_ids: List[str]
) -> StreamResponse:
return await self.post(f"segments/{segment_id}/addtargets", data={"target_ids": target_ids})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
self, segment_id: str, target_ids: List[str]
) -> StreamResponse:
return await self.post(f"segments/{segment_id}/addtargets", data={"target_ids": target_ids})
self, segment_id: str, target_ids: List[str]
) -> StreamResponse:
return await self.post(
f"segments/{segment_id}/addtargets", data={"target_ids": target_ids}
)

Comment on lines 582 to 586
self, segment_id: str, target_ids: List[str]
) -> StreamResponse:
return await self.post(f"segments/{segment_id}/deletetargets", data={"target_ids": target_ids})

def campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> Campaign:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
self, segment_id: str, target_ids: List[str]
) -> StreamResponse:
return await self.post(f"segments/{segment_id}/deletetargets", data={"target_ids": target_ids})
def campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> Campaign:
self, segment_id: str, target_ids: List[str]
) -> StreamResponse:
return await self.post(
f"segments/{segment_id}/deletetargets", data={"target_ids": target_ids}
)
def campaign(
self, campaign_id: Optional[str] = None, data: CampaignData = None
) -> Campaign:

def add_segment_targets(
self, segment_id: str, target_ids: List[str]
) -> StreamResponse:
return self.post(f"segments/{segment_id}/addtargets", data={"target_ids": target_ids})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
return self.post(f"segments/{segment_id}/addtargets", data={"target_ids": target_ids})
return self.post(
f"segments/{segment_id}/addtargets", data={"target_ids": target_ids}
)

Comment on lines 562 to 564
return self.post(f"segments/{segment_id}/deletetargets", data={"target_ids": target_ids})

def update_campaign(self, campaign_id: str, data: Dict) -> StreamResponse:
return self.put(f"campaigns/{campaign_id}", data={"campaign": data})
def campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> Campaign:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
return self.post(f"segments/{segment_id}/deletetargets", data={"target_ids": target_ids})
def update_campaign(self, campaign_id: str, data: Dict) -> StreamResponse:
return self.put(f"campaigns/{campaign_id}", data={"campaign": data})
def campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> Campaign:
return self.post(
f"segments/{segment_id}/deletetargets", data={"target_ids": target_ids}
)
def campaign(
self, campaign_id: Optional[str] = None, data: CampaignData = None
) -> Campaign:

Copy link
Contributor

@github-actions github-actions bot left a comment


class Campaign(CampaignInterface):

async def create(self, campaign_id: Optional[str] = None, data: Optional[CampaignData] = None) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
async def create(self, campaign_id: Optional[str] = None, data: Optional[CampaignData] = None) -> StreamResponse:
async def create(
self, campaign_id: Optional[str] = None, data: Optional[CampaignData] = None
) -> StreamResponse:

return await self.client.update_campaign(campaign_id=self.campaign_id, data=data)

async def delete(self, **options: Any) -> StreamResponse:
return await self.client.delete_campaign(campaign_id=self.campaign_id, **options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
return await self.client.delete_campaign(campaign_id=self.campaign_id, **options)
return await self.client.delete_campaign(
campaign_id=self.campaign_id, **options
)

from typing import Optional

from stream_chat.base.segment import SegmentInterface
from stream_chat.types.segment import SegmentData, SegmentDataWithId, QuerySegmentTargetsOptions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
from stream_chat.types.segment import SegmentData, SegmentDataWithId, QuerySegmentTargetsOptions
from stream_chat.types.segment import (
SegmentData,
SegmentDataWithId,
QuerySegmentTargetsOptions,
)


class Segment(SegmentInterface):

async def create(self, segment_id: Optional[str] = None, data: Optional[SegmentData] = None) -> StreamResponse:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
async def create(self, segment_id: Optional[str] = None, data: Optional[SegmentData] = None) -> StreamResponse:
async def create(
self, segment_id: Optional[str] = None, data: Optional[SegmentData] = None
) -> StreamResponse:

Comment on lines 44 to 45
async def query_targets(self, options: QuerySegmentTargetsOptions) -> StreamResponse:
return await self.client.query_segment_targets(segment_id=self.segment_id, options=options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
async def query_targets(self, options: QuerySegmentTargetsOptions) -> StreamResponse:
return await self.client.query_segment_targets(segment_id=self.segment_id, options=options)
async def query_targets(
self, options: QuerySegmentTargetsOptions
) -> StreamResponse:
return await self.client.query_segment_targets(
segment_id=self.segment_id, options=options
)

Comment on lines 29 to 32
updated = await segment.update({
"name": "updated_name",
"description": "updated_description",
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
updated = await segment.update({
"name": "updated_name",
"description": "updated_description",
})
updated = await segment.update(
{
"name": "updated_name",
"description": "updated_description",
}
)

Comment on lines 58 to 60
query_targets_1 = await segment.query_targets({
"limit": 3,
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
query_targets_1 = await segment.query_targets({
"limit": 3,
})
query_targets_1 = await segment.query_targets(
{
"limit": 3,
}
)

Comment on lines 66 to 69
query_targets_2 = await segment.query_targets({
"limit": 3,
"next": query_targets_1["next"],
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
query_targets_2 = await segment.query_targets({
"limit": 3,
"next": query_targets_1["next"],
})
query_targets_2 = await segment.query_targets(
{
"limit": 3,
"next": query_targets_1["next"],
}
)

Comment on lines 39 to 46
updated = campaign.update({
"message_template": {
"text": "{Hello}",
},
"segment_ids": [segment_id],
"sender_id": sender_id,
"name": "updated_name",
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
updated = campaign.update({
"message_template": {
"text": "{Hello}",
},
"segment_ids": [segment_id],
"sender_id": sender_id,
"name": "updated_name",
})
updated = campaign.update(
{
"message_template": {
"text": "{Hello}",
},
"segment_ids": [segment_id],
"sender_id": sender_id,
"name": "updated_name",
}
)

from stream_chat.campaign import Campaign
from stream_chat.segment import Segment
from stream_chat.types.campaign import QueryCampaignsOptions, CampaignData
from stream_chat.types.segment import SegmentType, QuerySegmentsOptions, SegmentData, QuerySegmentTargetsOptions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
from stream_chat.types.segment import SegmentType, QuerySegmentsOptions, SegmentData, QuerySegmentTargetsOptions
from stream_chat.types.segment import (
SegmentType,
QuerySegmentsOptions,
SegmentData,
QuerySegmentTargetsOptions,
)

from stream_chat.async_chat.campaign import Campaign
from stream_chat.async_chat.segment import Segment
from stream_chat.types.campaign import CampaignData, QueryCampaignsOptions
from stream_chat.types.segment import SegmentType, SegmentData, QuerySegmentsOptions, QuerySegmentTargetsOptions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position

from typing import Optional

from stream_chat.base.segment import SegmentInterface
from stream_chat.types.segment import SegmentData, SegmentDataWithId, QuerySegmentTargetsOptions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position

from typing import Optional

from stream_chat.base.segment import SegmentInterface
from stream_chat.types.segment import SegmentData, SegmentDataWithId, QuerySegmentTargetsOptions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[flake8] <401> reported by reviewdog 🐶
'stream_chat.types.segment.SegmentDataWithId' imported but unused


from stream_chat.base.segment import SegmentInterface
from stream_chat.types.segment import SegmentData, SegmentDataWithId, QuerySegmentTargetsOptions
from stream_chat.types.stream_response import StreamResponse
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <5> reported by reviewdog 🐶
isort found an unexpected missing import


from stream_chat.base.segment import SegmentInterface
from stream_chat.types.segment import SegmentData, SegmentDataWithId, QuerySegmentTargetsOptions
from stream_chat.types.stream_response import StreamResponse
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <5> reported by reviewdog 🐶
isort found an unexpected missing import

from stream_chat.campaign import Campaign
from stream_chat.segment import Segment
from stream_chat.types.campaign import QueryCampaignsOptions, CampaignData
from stream_chat.types.segment import SegmentType, QuerySegmentsOptions, SegmentData, QuerySegmentTargetsOptions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position

from typing import Optional

from stream_chat.base.segment import SegmentInterface
from stream_chat.types.segment import SegmentData, QuerySegmentTargetsOptions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position


from stream_chat.base.segment import SegmentInterface
from stream_chat.types.segment import SegmentData, QuerySegmentTargetsOptions
from stream_chat.types.stream_response import StreamResponse
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <5> reported by reviewdog 🐶
isort found an unexpected missing import

@@ -0,0 +1,36 @@
from enum import IntEnum
from typing import TypedDict, Optional
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position

@@ -0,0 +1,64 @@
import datetime
from typing import List, Optional, TypedDict, Dict, Union
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position

@@ -918,18 +924,39 @@ def list_roles(self) -> Union[StreamResponse, Awaitable[StreamResponse]]:
"""
pass

def segment(
self, segment_type: SegmentType, segment_id: Optional[str], data: Optional[SegmentData]
) -> TSegment:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var]


def campaign(
self, campaign_id: Optional[str], data: Optional[CampaignData]
) -> TCampaign:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
A function returning TypeVar should receive at least one argument containing the same TypeVar [type-var]

return self.client.add_segment_targets(segment_id=self.segment_id, target_ids=target_ids)

def query_targets(self, options: QuerySegmentTargetsOptions) -> StreamResponse:
return self.client.query_segment_targets(segment_id=self.segment_id, options=options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible return value type (got "StreamResponse | Awaitable[StreamResponse]", expected "StreamResponse") [return-value]

return self.client.update_campaign(campaign_id=self.campaign_id, data=data)

def delete(self, **options: Any) -> StreamResponse:
return self.client.delete_campaign(campaign_id=self.campaign_id, **options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible return value type (got "StreamResponse | Awaitable[StreamResponse]", expected "StreamResponse") [return-value]

return await self.client.add_segment_targets(segment_id=self.segment_id, target_ids=target_ids)

async def query_targets(self, options: QuerySegmentTargetsOptions) -> StreamResponse:
return await self.client.query_segment_targets(segment_id=self.segment_id, options=options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible types in "await" (actual type "StreamResponse | Awaitable[StreamResponse]", expected type "Awaitable[Any]") [misc]

) -> StreamResponse:
return await self.post(f"segments/{segment_id}/deletetargets", data={"target_ids": target_ids})

def campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> Campaign:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Signature of "campaign" incompatible with supertype "StreamChatInterface" [override]

) -> StreamResponse:
return await self.post(f"segments/{segment_id}/deletetargets", data={"target_ids": target_ids})

def campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> Campaign:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
Superclass:

) -> StreamResponse:
return await self.post(f"segments/{segment_id}/deletetargets", data={"target_ids": target_ids})

def campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> Campaign:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
def [TCampaign] campaign(self, campaign_id: str | None, data: CampaignData | None) -> TCampaign

) -> StreamResponse:
return await self.post(f"segments/{segment_id}/deletetargets", data={"target_ids": target_ids})

def campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> Campaign:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
Subclass:

) -> StreamResponse:
return await self.post(f"segments/{segment_id}/deletetargets", data={"target_ids": target_ids})

def campaign(self, campaign_id: Optional[str] = None, data: CampaignData = None) -> Campaign:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
def campaign(self, campaign_id: str | None = ..., data: CampaignData = ...) -> Campaign

from typing import Optional

from stream_chat.base.segment import SegmentInterface
from stream_chat.types.segment import (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[flake8] <401> reported by reviewdog 🐶
'stream_chat.types.segment.SegmentDataWithId' imported but unused

from typing import Awaitable, List, Optional, Union

from stream_chat.base.client import StreamChatInterface
from stream_chat.types.segment import (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[flake8] <401> reported by reviewdog 🐶
'stream_chat.types.segment.SegmentDataWithId' imported but unused

return self.client.get_segment(segment_id=self.segment_id)

def update(self, data: SegmentData) -> StreamResponse:
return self.client.update_segment(segment_id=self.segment_id, data=data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible return value type (got "StreamResponse | Awaitable[StreamResponse]", expected "StreamResponse") [return-value]

return self.client.delete_segment(segment_id=self.segment_id)

def target_exists(self, target_id: str) -> StreamResponse:
return self.client.segment_target_exists(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible return value type (got "StreamResponse | Awaitable[StreamResponse]", expected "StreamResponse") [return-value]

)

def add_targets(self, target_ids: list) -> StreamResponse:
return self.client.add_segment_targets(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible return value type (got "StreamResponse | Awaitable[StreamResponse]", expected "StreamResponse") [return-value]

)

def query_targets(self, options: QuerySegmentTargetsOptions) -> StreamResponse:
return self.client.query_segment_targets(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible return value type (got "StreamResponse | Awaitable[StreamResponse]", expected "StreamResponse") [return-value]

)

def delete_targets(self, target_ids: list) -> StreamResponse:
return self.client.delete_segment_targets(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible return value type (got "StreamResponse | Awaitable[StreamResponse]", expected "StreamResponse") [return-value]

)

async def query_recipients(self, **params: Any) -> StreamResponse:
return await self.get("recipients", params={"payload": json.dumps(params)})
def campaign(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Signature of "campaign" incompatible with supertype "StreamChatInterface" [override]

)

async def query_recipients(self, **params: Any) -> StreamResponse:
return await self.get("recipients", params={"payload": json.dumps(params)})
def campaign(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
Superclass:

)

async def query_recipients(self, **params: Any) -> StreamResponse:
return await self.get("recipients", params={"payload": json.dumps(params)})
def campaign(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
def [TCampaign] campaign(self, campaign_id: str | None, data: CampaignData | None) -> TCampaign

)

async def query_recipients(self, **params: Any) -> StreamResponse:
return await self.get("recipients", params={"payload": json.dumps(params)})
def campaign(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
Subclass:

)

async def query_recipients(self, **params: Any) -> StreamResponse:
return await self.get("recipients", params={"payload": json.dumps(params)})
def campaign(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
def campaign(self, campaign_id: str | None = ..., data: CampaignData = ...) -> Campaign

self,
filter_conditions: Optional[Dict[str, Any]] = None,
sort: Optional[List[SortParam]] = None,
options: Optional[QueryCampaignsOptions] = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
options: Optional[QueryCampaignsOptions] = None
options: Optional[QueryCampaignsOptions] = None,

segment_id = created["segment"]["id"]

target_ids = [str(uuid.uuid4()) for _ in range(10)]
target_added = await client.add_segment_targets(segment_id=segment_id, target_ids=target_ids)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
target_added = await client.add_segment_targets(segment_id=segment_id, target_ids=target_ids)
target_added = await client.add_segment_targets(
segment_id=segment_id, target_ids=target_ids
)

target_added = await client.add_segment_targets(segment_id=segment_id, target_ids=target_ids)
assert target_added.is_ok()

query_segments = await client.query_segments(filter_conditions={"id": {"$eq": segment_id}})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
query_segments = await client.query_segments(filter_conditions={"id": {"$eq": segment_id}})
query_segments = await client.query_segments(
filter_conditions={"id": {"$eq": segment_id}}
)

assert "segments" in query_segments
assert len(query_segments["segments"]) == 1

target_deleted = await client.remove_segment_targets(segment_id=segment_id, target_ids=target_ids)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
target_deleted = await client.remove_segment_targets(segment_id=segment_id, target_ids=target_ids)
target_deleted = await client.remove_segment_targets(
segment_id=segment_id, target_ids=target_ids
)

assert target_deleted.is_ok()

deleted = await client.delete_segment(segment_id=segment_id)
assert deleted.is_ok()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
assert deleted.is_ok()
assert deleted.is_ok()

self,
filter_conditions: Optional[Dict[str, Any]] = None,
sort: Optional[List[SortParam]] = None,
options: Optional[QuerySegmentsOptions] = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
options: Optional[QuerySegmentsOptions] = None
options: Optional[QuerySegmentsOptions] = None,

self,
filter_conditions: Optional[Dict[str, Any]] = None,
sort: Optional[List[SortParam]] = None,
options: Optional[QueryCampaignsOptions] = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
options: Optional[QueryCampaignsOptions] = None
options: Optional[QueryCampaignsOptions] = None,

segment_id = created["segment"]["id"]

target_ids = [str(uuid.uuid4()) for _ in range(10)]
target_added = client.add_segment_targets(segment_id=segment_id, target_ids=target_ids)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
target_added = client.add_segment_targets(segment_id=segment_id, target_ids=target_ids)
target_added = client.add_segment_targets(
segment_id=segment_id, target_ids=target_ids
)

target_added = client.add_segment_targets(segment_id=segment_id, target_ids=target_ids)
assert target_added.is_ok()

query_segments = client.query_segments(filter_conditions={"id": {"$eq": segment_id}})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
query_segments = client.query_segments(filter_conditions={"id": {"$eq": segment_id}})
query_segments = client.query_segments(
filter_conditions={"id": {"$eq": segment_id}}
)

assert "segments" in query_segments
assert len(query_segments["segments"]) == 1

target_deleted = client.remove_segment_targets(segment_id=segment_id, target_ids=target_ids)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black] reported by reviewdog 🐶

Suggested change
target_deleted = client.remove_segment_targets(segment_id=segment_id, target_ids=target_ids)
target_deleted = client.remove_segment_targets(
segment_id=segment_id, target_ids=target_ids
)

@@ -0,0 +1,66 @@
from typing import Dict, Optional, List
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position

@@ -0,0 +1,66 @@
from typing import Dict, Optional, List

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <5> reported by reviewdog 🐶
isort found an unexpected missing import

@@ -0,0 +1,64 @@
from typing import Dict, Optional, List
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <1> reported by reviewdog 🐶
isort found an import in the wrong position

@@ -0,0 +1,64 @@
from typing import Dict, Optional, List

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [flake8] <5> reported by reviewdog 🐶
isort found an unexpected missing import

assert target_deleted.is_ok()

deleted = await client.delete_segment(segment_id=segment_id)
assert deleted.is_ok()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [flake8] <292> reported by reviewdog 🐶
no newline at end of file

@@ -0,0 +1,70 @@
from typing import Dict, List, Optional, TypedDict

from stream_chat.types.base import Pager, SortParam
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[flake8] <401> reported by reviewdog 🐶
'stream_chat.types.base.SortParam' imported but unused

@@ -0,0 +1,40 @@
from enum import Enum
from typing import Dict, List, Optional, TypedDict
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[flake8] <401> reported by reviewdog 🐶
'typing.List' imported but unused

from enum import Enum
from typing import Dict, List, Optional, TypedDict

from stream_chat.types.base import Pager, SortParam
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[flake8] <401> reported by reviewdog 🐶
'stream_chat.types.base.SortParam' imported but unused

segment_id=self.segment_id, target_ids=target_ids
)

def query_targets(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Signature of "query_targets" incompatible with supertype "SegmentInterface" [override]

segment_id=self.segment_id, target_ids=target_ids
)

def query_targets(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
Superclass:

segment_id=self.segment_id, target_ids=target_ids
)

def query_targets(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
def query_targets(self, filter_conditions: dict[Any, Any] | None = ..., options: QuerySegmentTargetsOptions | None = ...) -> StreamResponse | Awaitable[StreamResponse]

segment_id=self.segment_id, target_ids=target_ids
)

def query_targets(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
Subclass:

segment_id=self.segment_id, target_ids=target_ids
)

def query_targets(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [mypy] reported by reviewdog 🐶
def query_targets(self, filter_conditions: dict[Any, Any] | None = ..., sort: list[SortParam] | None = ..., options: QuerySegmentTargetsOptions | None = ...) -> StreamResponse

if filter_conditions is not None:
payload["filter"] = filter_conditions
if sort is not None:
payload["sort"] = sort
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible types in assignment (expression has type "list[SortParam]", target has type "dict[str, Any]") [assignment]

if filter_conditions is not None:
payload["filter"] = filter_conditions
if sort is not None:
payload["sort"] = sort
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible types in assignment (expression has type "list[SortParam]", target has type "dict[str, Any]") [assignment]

if filter_conditions is not None:
payload["filter"] = filter_conditions
if sort is not None:
payload["sort"] = sort
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible types in assignment (expression has type "list[SortParam]", target has type "dict[str, Any]") [assignment]

if filter_conditions is not None:
payload["filter"] = filter_conditions
if sort is not None:
payload["sort"] = sort
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible types in assignment (expression has type "list[SortParam]", target has type "dict[str, Any]") [assignment]

if filter_conditions is not None:
payload["filter"] = filter_conditions
if sort is not None:
payload["sort"] = sort
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Incompatible types in assignment (expression has type "list[SortParam]", target has type "dict[str, Any]") [assignment]

@kanat kanat changed the title [PBE-1321] support campaign endpoints (WIP) [PBE-1321] support campaign endpoints Feb 22, 2024
@kanat
Copy link
Contributor Author

kanat commented Feb 22, 2024

Will recreate a PR

@kanat kanat closed this Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant