Skip to content

Commit

Permalink
chore: Code simplification via flake8-simplify (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
jirimoravcik authored Aug 1, 2023
1 parent 53d27d9 commit 1ade4e4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

[1.0.2](../../releases/tag/v1.0.2) - 2023-08-02

- Added the `ActorEnvVars` enum and new tests.
- Added the `flake8-simplify` package and simplified some code.

[1.0.1](../../releases/tag/v1.0.1) - 2023-08-01

Added the `ignore_docs` decorator to all internal utilities.
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ license = {text = "Apache Software License"}
name = "apify_shared"
readme = "README.md"
requires-python = ">=3.8"
version = "1.0.1"
version = "1.0.2"

[project.optional-dependencies]
dev = [
Expand All @@ -35,6 +35,7 @@ dev = [
"flake8-noqa ~= 1.3.1",
"flake8-pytest-style ~= 1.7.2",
"flake8-quotes ~= 3.3.2",
"flake8-simplify ~= 0.20.0",
"flake8-unused-arguments ~= 0.0.13",
"isort ~= 5.12.0",
"mypy ~= 1.4.0",
Expand Down
5 changes: 2 additions & 3 deletions src/apify_shared/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import contextlib
import io
import json
import re
Expand Down Expand Up @@ -100,10 +101,8 @@ def parse_date_fields(data: ListOrDict, max_depth: int = PARSE_DATE_FIELDS_MAX_D
def parse(key: str, value: object) -> object:
parsed_value = value
if key.endswith(PARSE_DATE_FIELDS_KEY_SUFFIX) and isinstance(value, str):
try:
with contextlib.suppress(ValueError):
parsed_value = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%fZ').replace(tzinfo=timezone.utc)
except ValueError:
pass
elif isinstance(value, dict):
parsed_value = parse_date_fields(value, max_depth - 1)
elif isinstance(value, list):
Expand Down

0 comments on commit 1ade4e4

Please sign in to comment.