Skip to content

Commit 98c77cd

Browse files
authored
Start using apify-shared for general consts and utils (#132)
Closes #131
1 parent f4fd627 commit 98c77cd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+245
-779
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ filename =
44
./scripts/*.py,
55
./src/*.py,
66
./tests/*.py
7+
# Todo: remove "src/apify_client/consts.py: F401" once consts are removed from the package
78
per-file-ignores =
89
docs/*: D
910
scripts/*: D
1011
tests/*: D
12+
src/apify_client/consts.py: F401
1113

1214
# Google docstring convention + D204 & D401
1315
docstring-convention = all

.isort.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ line_length = 150
44
use_parentheses = True
55
multi_line_output = 3
66
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
7-
known_first_party = apify_client
7+
known_first_party = apify_client, apify_shared

docs/docs.md

Lines changed: 0 additions & 255 deletions
Original file line numberDiff line numberDiff line change
@@ -6155,258 +6155,3 @@ List all webhook dispatches of a user.
61556155
* **Return type**
61566156

61576157
[`ListPage`](#listpage)
6158-
6159-
***
6160-
6161-
### [](#listpage) ListPage
6162-
6163-
A single page of items returned from a list() method.
6164-
6165-
#### Instance attributes
6166-
6167-
Name | Type | Description
6168-
---- | ---- | -----------
6169-
`items` | `list` | List of returned objects on this page
6170-
`offset` | `int` | The limit on the number of returned objects offset specified in the API call
6171-
`limit` | `int` | The offset of the first object specified in the API call
6172-
`count` | `int` | Count of the returned objects on this page
6173-
`total` | `int` | Total number of objects matching the API call criteria
6174-
`desc` | `bool` | Whether the listing is descending or not
6175-
6176-
***
6177-
6178-
### [](#actorjobstatus) ActorJobStatus
6179-
6180-
Available statuses for actor jobs (runs or builds).
6181-
6182-
* [READY](#actorjobstatus-ready)
6183-
* [RUNNING](#actorjobstatus-running)
6184-
* [SUCCEEDED](#actorjobstatus-succeeded)
6185-
* [FAILED](#actorjobstatus-failed)
6186-
* [TIMING\_OUT](#actorjobstatus-timing\_out)
6187-
* [TIMED\_OUT](#actorjobstatus-timed\_out)
6188-
* [ABORTING](#actorjobstatus-aborting)
6189-
* [ABORTED](#actorjobstatus-aborted)
6190-
6191-
***
6192-
6193-
#### [](#actorjobstatus-ready) `ActorJobStatus.READY`
6194-
6195-
Actor job initialized but not started yet
6196-
6197-
***
6198-
6199-
#### [](#actorjobstatus-running) `ActorJobStatus.RUNNING`
6200-
6201-
Actor job in progress
6202-
6203-
***
6204-
6205-
#### [](#actorjobstatus-succeeded) `ActorJobStatus.SUCCEEDED`
6206-
6207-
Actor job finished successfully
6208-
6209-
***
6210-
6211-
#### [](#actorjobstatus-failed) `ActorJobStatus.FAILED`
6212-
6213-
Actor job or build failed
6214-
6215-
***
6216-
6217-
#### [](#actorjobstatus-timing_out) `ActorJobStatus.TIMING_OUT`
6218-
6219-
Actor job currently timing out
6220-
6221-
***
6222-
6223-
#### [](#actorjobstatus-timed_out) `ActorJobStatus.TIMED_OUT`
6224-
6225-
Actor job timed out
6226-
6227-
***
6228-
6229-
#### [](#actorjobstatus-aborting) `ActorJobStatus.ABORTING`
6230-
6231-
Actor job currently being aborted by user
6232-
6233-
***
6234-
6235-
#### [](#actorjobstatus-aborted) `ActorJobStatus.ABORTED`
6236-
6237-
Actor job aborted by user
6238-
6239-
***
6240-
6241-
### [](#actorsourcetype) ActorSourceType
6242-
6243-
Available source types for actors.
6244-
6245-
* [SOURCE\_FILES](#actorsourcetype-source\_files)
6246-
* [GIT\_REPO](#actorsourcetype-git\_repo)
6247-
* [TARBALL](#actorsourcetype-tarball)
6248-
* [GITHUB\_GIST](#actorsourcetype-github\_gist)
6249-
6250-
***
6251-
6252-
#### [](#actorsourcetype-source_files) `ActorSourceType.SOURCE_FILES`
6253-
6254-
Actor source code is comprised of multiple files
6255-
6256-
***
6257-
6258-
#### [](#actorsourcetype-git_repo) `ActorSourceType.GIT_REPO`
6259-
6260-
Actor source code is cloned from a Git repository
6261-
6262-
***
6263-
6264-
#### [](#actorsourcetype-tarball) `ActorSourceType.TARBALL`
6265-
6266-
Actor source code is downloaded using a tarball or Zip file
6267-
6268-
***
6269-
6270-
#### [](#actorsourcetype-github_gist) `ActorSourceType.GITHUB_GIST`
6271-
6272-
Actor source code is taken from a GitHub Gist
6273-
6274-
***
6275-
6276-
### [](#webhookeventtype) WebhookEventType
6277-
6278-
Events that can trigger a webhook.
6279-
6280-
* [ACTOR\_RUN\_CREATED](#webhookeventtype-actor\_run\_created)
6281-
* [ACTOR\_RUN\_SUCCEEDED](#webhookeventtype-actor\_run\_succeeded)
6282-
* [ACTOR\_RUN\_FAILED](#webhookeventtype-actor\_run\_failed)
6283-
* [ACTOR\_RUN\_TIMED\_OUT](#webhookeventtype-actor\_run\_timed\_out)
6284-
* [ACTOR\_RUN\_ABORTED](#webhookeventtype-actor\_run\_aborted)
6285-
* [ACTOR\_RUN\_RESURRECTED](#webhookeventtype-actor\_run\_resurrected)
6286-
* [ACTOR\_BUILD\_CREATED](#webhookeventtype-actor\_build\_created)
6287-
* [ACTOR\_BUILD\_SUCCEEDED](#webhookeventtype-actor\_build\_succeeded)
6288-
* [ACTOR\_BUILD\_FAILED](#webhookeventtype-actor\_build\_failed)
6289-
* [ACTOR\_BUILD\_TIMED\_OUT](#webhookeventtype-actor\_build\_timed\_out)
6290-
* [ACTOR\_BUILD\_ABORTED](#webhookeventtype-actor\_build\_aborted)
6291-
6292-
***
6293-
6294-
#### [](#webhookeventtype-actor_run_created) `WebhookEventType.ACTOR_RUN_CREATED`
6295-
6296-
The actor run was created
6297-
6298-
***
6299-
6300-
#### [](#webhookeventtype-actor_run_succeeded) `WebhookEventType.ACTOR_RUN_SUCCEEDED`
6301-
6302-
The actor run has succeeded
6303-
6304-
***
6305-
6306-
#### [](#webhookeventtype-actor_run_failed) `WebhookEventType.ACTOR_RUN_FAILED`
6307-
6308-
The actor run has failed
6309-
6310-
***
6311-
6312-
#### [](#webhookeventtype-actor_run_timed_out) `WebhookEventType.ACTOR_RUN_TIMED_OUT`
6313-
6314-
The actor run has timed out
6315-
6316-
***
6317-
6318-
#### [](#webhookeventtype-actor_run_aborted) `WebhookEventType.ACTOR_RUN_ABORTED`
6319-
6320-
The actor run was aborted
6321-
6322-
***
6323-
6324-
#### [](#webhookeventtype-actor_run_resurrected) `WebhookEventType.ACTOR_RUN_RESURRECTED`
6325-
6326-
The actor run was resurrected
6327-
6328-
***
6329-
6330-
#### [](#webhookeventtype-actor_build_created) `WebhookEventType.ACTOR_BUILD_CREATED`
6331-
6332-
The actor build was created
6333-
6334-
***
6335-
6336-
#### [](#webhookeventtype-actor_build_succeeded) `WebhookEventType.ACTOR_BUILD_SUCCEEDED`
6337-
6338-
The actor build has succeeded
6339-
6340-
***
6341-
6342-
#### [](#webhookeventtype-actor_build_failed) `WebhookEventType.ACTOR_BUILD_FAILED`
6343-
6344-
The actor build has failed
6345-
6346-
***
6347-
6348-
#### [](#webhookeventtype-actor_build_timed_out) `WebhookEventType.ACTOR_BUILD_TIMED_OUT`
6349-
6350-
The actor build has timed out
6351-
6352-
***
6353-
6354-
#### [](#webhookeventtype-actor_build_aborted) `WebhookEventType.ACTOR_BUILD_ABORTED`
6355-
6356-
The actor build was aborted
6357-
6358-
***
6359-
6360-
### [](#metaorigin) MetaOrigin
6361-
6362-
Possible origins for actor runs, i.e. how were the jobs started.
6363-
6364-
* [DEVELOPMENT](#metaorigin-development)
6365-
* [WEB](#metaorigin-web)
6366-
* [API](#metaorigin-api)
6367-
* [SCHEDULER](#metaorigin-scheduler)
6368-
* [TEST](#metaorigin-test)
6369-
* [WEBHOOK](#metaorigin-webhook)
6370-
* [ACTOR](#metaorigin-actor)
6371-
6372-
***
6373-
6374-
#### [](#metaorigin-development) `MetaOrigin.DEVELOPMENT`
6375-
6376-
Job started from Developer console in Source section of actor
6377-
6378-
***
6379-
6380-
#### [](#metaorigin-web) `MetaOrigin.WEB`
6381-
6382-
Job started from other place on the website (either console or task detail page)
6383-
6384-
***
6385-
6386-
#### [](#metaorigin-api) `MetaOrigin.API`
6387-
6388-
Job started through API
6389-
6390-
***
6391-
6392-
#### [](#metaorigin-scheduler) `MetaOrigin.SCHEDULER`
6393-
6394-
Job started through Scheduler
6395-
6396-
***
6397-
6398-
#### [](#metaorigin-test) `MetaOrigin.TEST`
6399-
6400-
Job started through test actor page
6401-
6402-
***
6403-
6404-
#### [](#metaorigin-webhook) `MetaOrigin.WEBHOOK`
6405-
6406-
Job started by the webhook
6407-
6408-
***
6409-
6410-
#### [](#metaorigin-actor) `MetaOrigin.ACTOR`
6411-
6412-
Job started by another actor run

docs/res/sphinx-config/index.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,3 @@
77
:members:
88
.. automodule:: apify_client.clients.resource_clients
99
:members:
10-
.. autoclass:: apify_client._utils.ListPage
11-
:members:
12-
.. automodule:: apify_client.consts
13-
:members:

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = "Apify API client for Python"
55
readme = "README.md"
66
license = {text = "Apache Software License"}
77
authors = [
8-
{name = "Apify Technologies s.r.o.", email = "[email protected]" }
8+
{name = "Apify Technologies s.r.o.", email = "[email protected]"},
99
]
1010
keywords = ["apify", "api", "client", "scraping", "automation"]
1111

@@ -23,7 +23,8 @@ classifiers = [
2323

2424
requires-python = ">=3.8"
2525
dependencies = [
26-
"httpx >= 0.24.1"
26+
"apify-shared ~= 1.0.0",
27+
"httpx >= 0.24.1",
2728
]
2829

2930
[project.optional-dependencies]

src/apify_client/_errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import httpx
44

5-
from ._utils import ignore_docs
5+
from apify_shared.utils import ignore_docs
66

77

88
class ApifyClientError(Exception):

src/apify_client/_http_client.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,12 @@
99

1010
import httpx
1111

12+
from apify_shared.types import JSONSerializable
13+
from apify_shared.utils import ignore_docs, is_content_type_json, is_content_type_text, is_content_type_xml
14+
1215
from ._errors import ApifyApiError, InvalidResponseBodyError, _is_retryable_error
1316
from ._logging import logger_name
14-
from ._types import JSONSerializable
15-
from ._utils import (
16-
_is_content_type_json,
17-
_is_content_type_text,
18-
_is_content_type_xml,
19-
_retry_with_exp_backoff,
20-
_retry_with_exp_backoff_async,
21-
ignore_docs,
22-
)
17+
from ._utils import _retry_with_exp_backoff, _retry_with_exp_backoff_async
2318

2419
DEFAULT_BACKOFF_EXPONENTIAL_FACTOR = 2
2520
DEFAULT_BACKOFF_RANDOM_FACTOR = 1
@@ -70,9 +65,9 @@ def _maybe_parse_response(response: httpx.Response) -> Any:
7065
content_type = response.headers['content-type'].split(';')[0].strip()
7166

7267
try:
73-
if _is_content_type_json(content_type):
68+
if is_content_type_json(content_type):
7469
return response.json()
75-
elif _is_content_type_xml(content_type) or _is_content_type_text(content_type):
70+
elif is_content_type_xml(content_type) or is_content_type_text(content_type):
7671
return response.text
7772
else:
7873
return response.content

src/apify_client/_types.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)