Skip to content

Commit 1ade4e4

Browse files
authored
chore: Code simplification via flake8-simplify (#6)
1 parent 53d27d9 commit 1ade4e4

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
[1.0.2](../../releases/tag/v1.0.2) - 2023-08-02
4+
5+
- Added the `ActorEnvVars` enum and new tests.
6+
- Added the `flake8-simplify` package and simplified some code.
7+
38
[1.0.1](../../releases/tag/v1.0.1) - 2023-08-01
49

510
Added the `ignore_docs` decorator to all internal utilities.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ license = {text = "Apache Software License"}
1818
name = "apify_shared"
1919
readme = "README.md"
2020
requires-python = ">=3.8"
21-
version = "1.0.1"
21+
version = "1.0.2"
2222

2323
[project.optional-dependencies]
2424
dev = [
@@ -35,6 +35,7 @@ dev = [
3535
"flake8-noqa ~= 1.3.1",
3636
"flake8-pytest-style ~= 1.7.2",
3737
"flake8-quotes ~= 3.3.2",
38+
"flake8-simplify ~= 0.20.0",
3839
"flake8-unused-arguments ~= 0.0.13",
3940
"isort ~= 5.12.0",
4041
"mypy ~= 1.4.0",

src/apify_shared/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import contextlib
12
import io
23
import json
34
import re
@@ -100,10 +101,8 @@ def parse_date_fields(data: ListOrDict, max_depth: int = PARSE_DATE_FIELDS_MAX_D
100101
def parse(key: str, value: object) -> object:
101102
parsed_value = value
102103
if key.endswith(PARSE_DATE_FIELDS_KEY_SUFFIX) and isinstance(value, str):
103-
try:
104+
with contextlib.suppress(ValueError):
104105
parsed_value = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%fZ').replace(tzinfo=timezone.utc)
105-
except ValueError:
106-
pass
107106
elif isinstance(value, dict):
108107
parsed_value = parse_date_fields(value, max_depth - 1)
109108
elif isinstance(value, list):

0 commit comments

Comments
 (0)