Skip to content

Commit

Permalink
fix: fixed TypeError: unsupported operand type(s) for //: 'NoneType' …
Browse files Browse the repository at this point in the history
…and 'int'
  • Loading branch information
Ljzd-PRO committed Mar 29, 2024
1 parent a9e90d2 commit 5490fb1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions ktoolbox/action/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async def create_job_from_creator(
*,
all_pages: bool = False,
offset: int = 0,
length: int = 50,
length: Optional[int] = 50,
save_creator_indices: bool = True,
mix_posts: bool = None,
start_time: Optional[datetime],
Expand All @@ -125,8 +125,11 @@ async def create_job_from_creator(
logger.info(f"Start fetching posts from creator {creator_id}")
post_list: List[Post] = []
start_offset = offset - offset % 50
page_num = length // 50 + 1
page_counter = count() if all_pages else iter(range(page_num))
if all_pages:
page_counter = count()
else:
page_num = length // 50 + 1
page_counter = iter(range(page_num))

Check warning on line 132 in ktoolbox/action/job.py

View check run for this annotation

Codecov / codecov/patch

ktoolbox/action/job.py#L131-L132

Added lines #L131 - L132 were not covered by tests

try:
async for part in fetch_creator_posts(service=service, creator_id=creator_id, o=start_offset):
Expand All @@ -139,6 +142,8 @@ async def create_job_from_creator(

if not all_pages:
post_list = post_list[offset % 50:][:length]

Check warning on line 144 in ktoolbox/action/job.py

View check run for this annotation

Codecov / codecov/patch

ktoolbox/action/job.py#L144

Added line #L144 was not covered by tests
else:
post_list = post_list[offset % 50:]

# Filter posts by publish time
if start_time or end_time:
Expand Down
2 changes: 1 addition & 1 deletion ktoolbox/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ async def sync_creator(
Set to latest time (infinity) if ``None`` was given. \
Time format: ``%Y-%m-%d``
:param offset: Result offset (or start offset)
:param length: The number of posts to fetch, defaults to fetching all posts.
:param length: The number of posts to fetch, defaults to fetching all posts after ``offset``.
"""
# Get service, creator_id
if url:
Expand Down

0 comments on commit 5490fb1

Please sign in to comment.