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

Enable union-attr mypy check and fix issues #10942

Merged
merged 23 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add docstring, fix error in brokers and lock module
  • Loading branch information
ancalita committed Feb 24, 2022
commit 4a6e4b65680579c4cf2f7b9da94a0f2aee63332d
6 changes: 4 additions & 2 deletions rasa/core/brokers/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,12 @@ def _publish(self, event: Dict[Text, Any]) -> None:
f" key={partition_key!s}, headers={headers})"
)

self.producer.send(self.topic, value=event, key=partition_key, headers=headers)
if self.producer is not None:
self.producer.send(self.topic, value=event, key=partition_key, headers=headers)

def _close(self) -> None:
self.producer.close()
if self.producer is not None:
self.producer.close()

@rasa.shared.utils.common.lazy_property
def rasa_environment(self) -> Optional[Text]:
Expand Down
6 changes: 6 additions & 0 deletions rasa/core/brokers/pika.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ async def close(self) -> None:

def is_ready(self) -> bool:
"""Return `True` if a connection was established."""
if self._connection is None:
return False

return not self._connection.is_closed

def publish(
Expand All @@ -262,6 +265,9 @@ def publish(
async def _publish(
self, event: Dict[Text, Any], headers: Optional[Dict[Text, Text]] = None
) -> None:
if self._exchange is None:
return

try:
await self._exchange.publish(self._message(event, headers), "")

Expand Down
1 change: 1 addition & 0 deletions rasa/core/channels/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ async def stream(resp: Any) -> None:
def blueprint(
self, on_new_message: Callable[[UserMessage], Awaitable[None]]
) -> Blueprint:
"""Groups the collection of endpoints used by rest channel."""
module_type = inspect.getmodule(self)
if module_type is not None:
module_name = module_type.__name__
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(
def from_dict(cls, data: Dict[Text, Any]) -> "TicketLock":
"""Create `TicketLock` from dictionary."""

tickets = [Ticket.from_dict(json.loads(d)) for d in data.get("tickets")]
tickets = [Ticket.from_dict(json.loads(d)) for d in data.get("tickets", [])]
return cls(data.get("conversation_id"), deque(tickets))

def dumps(self) -> Text:
Expand Down