-
Notifications
You must be signed in to change notification settings - Fork 23
refactor!: Mark secondary arguments as keyword-only #917
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,3 +9,24 @@ This guide lists the breaking changes between Apify Python SDK v3.x and v4.0. | |||||
| ## Python 3.11+ required | ||||||
|
|
||||||
| Support for Python 3.10 has been dropped. The Apify Python SDK v4.x now requires Python 3.11 or later — make sure your environment is on a compatible version before upgrading. | ||||||
|
|
||||||
| ## Keyword-only arguments | ||||||
|
|
||||||
| Secondary parameters on these methods can no longer be passed positionally. | ||||||
|
|
||||||
| ```python | ||||||
| # Before | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| value = await Actor.get_value('my-key', default_value) | ||||||
| await Actor.push_data(data, 'my-event') | ||||||
| await Actor.charge('my-event', 5) | ||||||
|
|
||||||
| # After | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| value = await Actor.get_value('my-key', default_value=default_value) | ||||||
| await Actor.push_data(data, charged_event_name='my-event') | ||||||
| await Actor.charge('my-event', count=5) | ||||||
| ``` | ||||||
|
|
||||||
| Affected signatures: | ||||||
|
|
||||||
| - `Actor` — `get_value`, `push_data`, `charge`, `use_state`. | ||||||
| - `ChargingManager` — `charge`. | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -625,7 +625,7 @@ async def open_request_queue( | |
| ) | ||
|
|
||
| @_ensure_context | ||
| async def push_data(self, data: dict | list[dict], charged_event_name: str | None = None) -> ChargeResult: | ||
| async def push_data(self, data: dict | list[dict], *, charged_event_name: str | None = None) -> ChargeResult: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not so sure about this — |
||
| """Store an object or a list of objects to the default dataset of the current Actor run. | ||
|
|
||
| Args: | ||
|
|
@@ -701,7 +701,7 @@ async def get_input(self) -> Any: | |
| return input_value | ||
|
|
||
| @_ensure_context | ||
| async def get_value(self, key: str, default_value: Any = None) -> Any: | ||
| async def get_value(self, key: str, *, default_value: Any = None) -> Any: | ||
| """Get a value from the default key-value store associated with the current Actor run. | ||
|
|
||
| Args: | ||
|
|
@@ -735,7 +735,7 @@ def get_charging_manager(self) -> ChargingManager: | |
| return self._charging_manager_implementation | ||
|
|
||
| @_ensure_context | ||
| async def charge(self, event_name: str, count: int = 1) -> ChargeResult: | ||
| async def charge(self, event_name: str, *, count: int = 1) -> ChargeResult: | ||
| """Charge for a specified number of events - sub-operations of the Actor. | ||
|
|
||
| This is relevant only for the pay-per-event pricing model. | ||
|
|
@@ -746,7 +746,7 @@ async def charge(self, event_name: str, count: int = 1) -> ChargeResult: | |
| """ | ||
| # charging_manager.charge() acquires charge_lock internally. | ||
| charging_manager = self.get_charging_manager() | ||
| return await charging_manager.charge(event_name, count) | ||
| return await charging_manager.charge(event_name, count=count) | ||
|
|
||
| @overload | ||
| def on( | ||
|
|
@@ -1397,6 +1397,7 @@ async def create_proxy_configuration( | |
| async def use_state( | ||
| self, | ||
| default_value: dict[str, JsonSerializable] | None = None, | ||
| *, | ||
| key: str | None = None, | ||
| kvs_name: str | None = None, | ||
| ) -> MutableMapping[str, JsonSerializable]: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little awkward that we start with
these methodsbut don't list them right away. How about something like this?