Skip to content

Commit

Permalink
Merge pull request locustio#2779 from tdadela/dispatch_typing_strict_…
Browse files Browse the repository at this point in the history
…optional

Typing: strict optional in dispatch.py
  • Loading branch information
cyberw authored Jul 5, 2024
2 parents 0da8fa1 + ce8c711 commit 78705ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
13 changes: 7 additions & 6 deletions locust/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ def __init__(self, worker_nodes: list[WorkerNode], user_classes: list[type[User]
assert len(user_classes) > 0
assert len(set(self._user_classes)) == len(self._user_classes)

self._target_user_count: int = None
self._target_user_count: int = 0

self._spawn_rate: float = None
self._spawn_rate: float = 0.0

self._user_count_per_dispatch_iteration: int = None
self._user_count_per_dispatch_iteration: int = 0

self._wait_between_dispatch: float = None
self._wait_between_dispatch: float = 0.0

self._initial_users_on_workers = {
worker_node.id: {user_class.__name__: 0 for user_class in self._user_classes}
Expand All @@ -107,7 +107,8 @@ def __init__(self, worker_nodes: list[WorkerNode], user_classes: list[type[User]

self._current_user_count = self.get_current_user_count()

self._dispatcher_generator: Generator[dict[str, dict[str, int]], None, None] = None
self._dispatcher_generator: Generator[dict[str, dict[str, int]], None, None] = None # type: ignore
# a generator is assigned (in new_dispatch()) to _dispatcher_generator before it's used

self._user_generator = self._user_gen()

Expand All @@ -131,7 +132,7 @@ def get_current_user_count(self) -> int:
return sum(map(sum, map(dict.values, self._users_on_workers.values())))

@property
def dispatch_in_progress(self):
def dispatch_in_progress(self) -> bool:
return self._dispatch_in_progress

@property
Expand Down
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,6 @@ locust = ["locust"]
ignore_missing_imports = true
python_version = "3.9"

[[tool.mypy.overrides]]
module = ["locust.dispatch"]
strict_optional = false

[tool.pyright]
exclude = ["locust/test"]
reportOptionalMemberAccess = "none"
Expand Down

0 comments on commit 78705ae

Please sign in to comment.