Skip to content

Commit 805bfad

Browse files
committed
refactor!: Remove unused models, types and utils
1 parent b023caf commit 805bfad

File tree

14 files changed

+695
-2499
lines changed

14 files changed

+695
-2499
lines changed

.github/workflows/run_code_checks.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,19 @@ name: Run code checks
22

33
on:
44
# Trigger code checks on opening a new pull request.
5+
# Secrets are only made available to the integration tests job, with a manual approval
6+
# step required for PRs from forks. This prevents their potential exposure.
57
pull_request:
6-
workflow_call:
8+
9+
# Pushing to the master branch triggers code checks
10+
push:
11+
branches:
12+
- master
13+
tags-ignore:
14+
- "**" # Ignore all tags to prevent duplicate checks when tags are pushed.
15+
16+
# It should also be possible to trigger checks manually
17+
workflow_dispatch:
718

819
jobs:
920
lint_check:

.pre-commit-config.yaml

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

Makefile

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
.PHONY: clean install-dev build publish-to-pypi lint unit-tests unit-tests-cov \
2-
type-check check-code format
3-
4-
DIRS_WITH_CODE = src tests
2+
type-check check-code format
53

64
clean:
7-
rm -rf build dist .mypy_cache .pytest_cache .ruff_cache src/*.egg-info __pycache__ htmlcov .coverage
5+
rm -rf .mypy_cache .pytest_cache .ruff_cache build dist htmlcov .coverage
86

97
install-dev:
108
uv sync --all-extras
11-
uv run pre-commit install
129

1310
build:
1411
uv build --verbose
@@ -18,8 +15,8 @@ publish-to-pypi:
1815
uv publish --verbose --token "${APIFY_PYPI_TOKEN_CRAWLEE}"
1916

2017
lint:
21-
uv run ruff format --check $(DIRS_WITH_CODE)
22-
uv run ruff check $(DIRS_WITH_CODE)
18+
uv run ruff format --check
19+
uv run ruff check
2320

2421
unit-tests:
2522
uv run pytest --numprocesses=auto --verbose --cov=src/apify_shared tests/unit
@@ -28,11 +25,12 @@ unit-tests-cov:
2825
uv run pytest --numprocesses=auto --verbose --cov=src/apify_shared --cov-report=html tests/unit
2926

3027
type-check:
31-
uv run mypy $(DIRS_WITH_CODE)
28+
uv run mypy
3229

3330
# The check-code target runs a series of checks equivalent to those performed by pre-commit hooks
31+
# and the run_checks.yaml GitHub Actions workflow.
3432
check-code: lint type-check unit-tests
3533

3634
format:
37-
uv run ruff check --fix $(DIRS_WITH_CODE)
38-
uv run ruff format $(DIRS_WITH_CODE)
35+
uv run ruff check --fix
36+
uv run ruff format

mypy.ini

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

pyproject.toml

Lines changed: 70 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,114 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
15
[project]
26
name = "apify_shared"
37
version = "1.5.0"
48
description = "Tools and constants shared across Apify projects."
5-
readme = "README.md"
6-
license = { text = "Apache Software License" }
79
authors = [{ name = "Apify Technologies s.r.o.", email = "[email protected]" }]
8-
keywords = ["apify", "api", "shared", "scraping", "automation"]
9-
10+
license = { file = "LICENSE" }
11+
readme = "README.md"
12+
requires-python = ">=3.10"
1013
classifiers = [
1114
"Development Status :: 5 - Production/Stable",
15+
"Environment :: Console",
1216
"Intended Audience :: Developers",
1317
"License :: OSI Approved :: Apache Software License",
1418
"Operating System :: OS Independent",
15-
"Programming Language :: Python :: 3.8",
16-
"Programming Language :: Python :: 3.9",
1719
"Programming Language :: Python :: 3.10",
1820
"Programming Language :: Python :: 3.11",
1921
"Programming Language :: Python :: 3.12",
22+
"Programming Language :: Python :: 3.13",
2023
"Topic :: Software Development :: Libraries",
2124
]
22-
23-
requires-python = ">=3.8"
24-
25-
# We use inclusive ordered comparison clause for non-Apify packages intentionally in order to enhance the Apify
26-
# packages's compatibility with a wide range of external packages. This decision was discussed in detail in
27-
# the following PR: https://github.com/apify/apify-sdk-python/pull/154
28-
dependencies = []
29-
30-
[project.optional-dependencies]
31-
dev = [
32-
"build ~= 1.0.3",
33-
"filelock ~= 3.12.4",
34-
"mypy ~= 1.7.1",
35-
"pre-commit ~= 3.4.0",
36-
"pydoc-markdown ~= 4.8.2",
37-
"pytest ~= 7.4.2",
38-
"pytest-asyncio ~= 0.21.0",
39-
"pytest-cov ~= 4.1.0",
40-
"pytest-only ~= 2.0.0",
41-
"pytest-timeout ~= 2.2.0",
42-
"pytest-xdist ~= 3.3.1",
43-
"respx ~= 0.20.1",
44-
"ruff ~= 0.1.13",
45-
"setuptools >= 68.0.0",
46-
"twine ~= 5.1.1",
25+
keywords = [
26+
"apify",
27+
"automation",
28+
"chrome",
29+
"crawlee",
30+
"crawler",
31+
"headless",
32+
"scraper",
33+
"scraping",
4734
]
35+
dependencies = []
4836

4937
[project.urls]
5038
"Apify Homepage" = "https://apify.com"
5139
"Changelog" = "https://github.com/apify/apify-shared-python/blob/master/CHANGELOG.md"
52-
"Issue tracker" = "https://github.com/apify/apify-shared-python/issues"
53-
"Source" = "https://github.com/apify/apify-shared-python"
40+
"Discord" = "https://discord.com/invite/jyEM2PRvMU"
41+
"Issue Tracker" = "https://github.com/apify/apify-shared-python/issues"
42+
"Source Code" = "https://github.com/apify/apify-shared-python"
5443

55-
[build-system]
56-
build-backend = "setuptools.build_meta"
57-
requires = ["setuptools>=68.0.0", "wheel"]
58-
59-
[tool.setuptools.packages.find]
60-
include = ["apify_shared*"]
61-
where = ["src"]
44+
[dependency-groups]
45+
dev = [
46+
"dycw-pytest-only~=2.1.0",
47+
"mypy~=1.17.0",
48+
"pytest-asyncio~=1.1.0",
49+
"pytest-cov~=6.2.0",
50+
"pytest-timeout~=2.4.0",
51+
"pytest-xdist~=3.8.0",
52+
"pytest~=8.4.0",
53+
"ruff~=0.12.0",
54+
"setuptools", # setuptools are used by pytest, but not explicitly required
6255

63-
[tool.setuptools.package-data]
64-
apify_shared = ["py.typed"]
56+
]
6557

6658
[tool.ruff]
6759
line-length = 120
60+
include = ["src/**/*.py", "tests/**/*.py"]
61+
62+
[tool.ruff.lint]
6863
select = ["ALL"]
6964
ignore = [
70-
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in {filename}
71-
"BLE001", # Do not catch blind exception
72-
"C901", # `{name}` is too complex
73-
"COM812", # This rule may cause conflicts when used with the formatter
74-
"D100", # Missing docstring in public module
75-
"D104", # Missing docstring in public package
76-
"EM", # flake8-errmsg
77-
"G004", # Logging statement uses f-string
78-
"ISC001", # This rule may cause conflicts when used with the formatter
79-
"FIX", # flake8-fixme
80-
"PGH003", # Use specific rule codes when ignoring type issues
81-
"PLR0911", # Too many return statements
82-
"PLR0913", # Too many arguments in function definition
83-
"PLR0915", # Too many statements
84-
"PTH", # flake8-use-pathlib
85-
"PYI034", # `__aenter__` methods in classes like `{name}` usually return `self` at runtime
86-
"PYI036", # The second argument in `__aexit__` should be annotated with `object` or `BaseException | None`
87-
"S102", # Use of `exec` detected
88-
"S105", # Possible hardcoded password assigned to
89-
"S106", # Possible hardcoded password assigned to argument: "{name}"
90-
"S301", # `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue
91-
"S303", # Use of insecure MD2, MD4, MD5, or SHA1 hash function
92-
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
93-
"TD002", # Missing author in TODO; try: `# TODO(<author_name>): ...` or `# TODO @<author_name>: ...
94-
"TRY003", # Avoid specifying long messages outside the exception class
65+
"COM812", # This rule may cause conflicts when used with the formatter
66+
"D100", # Missing docstring in public module
67+
"D104", # Missing docstring in public package
68+
"D107", # Missing docstring in `__init__`
69+
"D203", # One blank line required before class docstring
70+
"D213", # Multi-line docstring summary should start at the second line
71+
"D413", # Missing blank line after last section
72+
"EM", # flake8-errmsg
73+
"ISC001", # This rule may cause conflicts when used with the formatter
74+
"S105", # Possible hardcoded password assigned to
75+
"TRY003", # Avoid specifying long messages outside the exception class
9576
]
9677

97-
[tool.ruff.format]
98-
quote-style = "single"
99-
indent-style = "space"
100-
10178
[tool.ruff.lint.per-file-ignores]
10279
"**/__init__.py" = [
10380
"F401", # Unused imports
10481
]
105-
"**/{scripts}/*" = [
106-
"D", # Everything from the pydocstyle
107-
"INP001", # File {filename} is part of an implicit namespace package, add an __init__.py
108-
"PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
109-
"T20", # flake8-print
110-
]
11182
"**/{tests}/*" = [
11283
"D", # Everything from the pydocstyle
11384
"INP001", # File {filename} is part of an implicit namespace package, add an __init__.py
114-
"PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
11585
"S101", # Use of assert detected
116-
"T20", # flake8-print
117-
"TRY301", # Abstract `raise` to an inner function
11886
]
11987

88+
[tool.ruff.format]
89+
quote-style = "single"
90+
indent-style = "space"
91+
12092
[tool.ruff.lint.flake8-quotes]
12193
docstring-quotes = "double"
12294
inline-quotes = "single"
12395

124-
[tool.ruff.lint.isort]
125-
known-local-folder = ["apify_shared"]
96+
[tool.pytest.ini_options]
97+
addopts = "-ra"
98+
asyncio_default_fixture_loop_scope = "function"
99+
asyncio_mode = "auto"
100+
timeout = 300
126101

127-
[tool.ruff.lint.pydocstyle]
128-
convention = "google"
102+
[tool.mypy]
103+
python_version = "3.10"
104+
files = ["src", "tests"]
105+
check_untyped_defs = true
106+
disallow_incomplete_defs = true
107+
disallow_untyped_calls = true
108+
disallow_untyped_decorators = true
109+
disallow_untyped_defs = true
110+
no_implicit_optional = true
111+
warn_redundant_casts = true
112+
warn_return_any = true
113+
warn_unreachable = true
114+
warn_unused_ignores = true

pytest.ini

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

0 commit comments

Comments
 (0)