urlscope 0.1.3rc1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. urlscope-0.1.3rc1/.github/workflows/ci.yml +46 -0
  2. urlscope-0.1.3rc1/.github/workflows/publish-pypi.yml +58 -0
  3. urlscope-0.1.3rc1/.github/workflows/publish-testpypi.yml +60 -0
  4. urlscope-0.1.3rc1/.github/workflows/release.yml +59 -0
  5. urlscope-0.1.3rc1/.gitignore +247 -0
  6. urlscope-0.1.3rc1/AGENTS.md +44 -0
  7. urlscope-0.1.3rc1/LICENSE +21 -0
  8. urlscope-0.1.3rc1/PKG-INFO +176 -0
  9. urlscope-0.1.3rc1/README.md +158 -0
  10. urlscope-0.1.3rc1/pyproject.toml +45 -0
  11. urlscope-0.1.3rc1/specs/001-urlscan-api-wrapper/checklists/requirements.md +36 -0
  12. urlscope-0.1.3rc1/specs/001-urlscan-api-wrapper/contracts/public-api.md +179 -0
  13. urlscope-0.1.3rc1/specs/001-urlscan-api-wrapper/data-model.md +213 -0
  14. urlscope-0.1.3rc1/specs/001-urlscan-api-wrapper/plan.md +90 -0
  15. urlscope-0.1.3rc1/specs/001-urlscan-api-wrapper/quickstart.md +130 -0
  16. urlscope-0.1.3rc1/specs/001-urlscan-api-wrapper/research.md +110 -0
  17. urlscope-0.1.3rc1/specs/001-urlscan-api-wrapper/spec.md +209 -0
  18. urlscope-0.1.3rc1/specs/001-urlscan-api-wrapper/tasks.md +262 -0
  19. urlscope-0.1.3rc1/src/urlscope/__init__.py +54 -0
  20. urlscope-0.1.3rc1/src/urlscope/_client.py +158 -0
  21. urlscope-0.1.3rc1/src/urlscope/_exceptions.py +52 -0
  22. urlscope-0.1.3rc1/src/urlscope/_http.py +155 -0
  23. urlscope-0.1.3rc1/src/urlscope/_sync.py +165 -0
  24. urlscope-0.1.3rc1/src/urlscope/models/__init__.py +27 -0
  25. urlscope-0.1.3rc1/src/urlscope/models/_quota.py +62 -0
  26. urlscope-0.1.3rc1/src/urlscope/models/_result.py +96 -0
  27. urlscope-0.1.3rc1/src/urlscope/models/_search.py +21 -0
  28. urlscope-0.1.3rc1/src/urlscope/models/_submission.py +16 -0
  29. urlscope-0.1.3rc1/src/urlscope/py.typed +1 -0
  30. urlscope-0.1.3rc1/tests/conftest.py +183 -0
  31. urlscope-0.1.3rc1/tests/test_artifacts.py +62 -0
  32. urlscope-0.1.3rc1/tests/test_auth.py +38 -0
  33. urlscope-0.1.3rc1/tests/test_context.py +50 -0
  34. urlscope-0.1.3rc1/tests/test_errors.py +166 -0
  35. urlscope-0.1.3rc1/tests/test_quota.py +69 -0
  36. urlscope-0.1.3rc1/tests/test_result.py +135 -0
  37. urlscope-0.1.3rc1/tests/test_retry.py +172 -0
  38. urlscope-0.1.3rc1/tests/test_search.py +131 -0
  39. urlscope-0.1.3rc1/tests/test_submit.py +101 -0
  40. urlscope-0.1.3rc1/tests/test_sync.py +170 -0
@@ -0,0 +1,46 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+
9
+ jobs:
10
+ checks:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ python-version:
16
+ - "3.10"
17
+ - "3.11"
18
+ - "3.12"
19
+ - "3.13"
20
+
21
+ steps:
22
+ - name: Check out repository
23
+ uses: actions/checkout@v6
24
+
25
+ - name: Set up uv
26
+ uses: astral-sh/setup-uv@v7
27
+ with:
28
+ enable-cache: true
29
+ cache-dependency-glob: pyproject.toml
30
+
31
+ - name: Set up Python
32
+ uses: actions/setup-python@v6
33
+ with:
34
+ python-version: ${{ matrix.python-version }}
35
+
36
+ - name: Install dependencies
37
+ run: uv sync --extra dev
38
+
39
+ - name: Run tests
40
+ run: uv run pytest tests/
41
+
42
+ - name: Run Ruff
43
+ run: uv run ruff check src/ tests/
44
+
45
+ - name: Run mypy
46
+ run: uv run mypy src/
@@ -0,0 +1,58 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ publish:
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ id-token: write
14
+
15
+ steps:
16
+ - name: Check out repository
17
+ uses: actions/checkout@v6
18
+
19
+ - name: Set up uv
20
+ uses: astral-sh/setup-uv@v7
21
+ with:
22
+ enable-cache: true
23
+ cache-dependency-glob: pyproject.toml
24
+
25
+ - name: Set up Python
26
+ uses: actions/setup-python@v6
27
+ with:
28
+ python-version: "3.11"
29
+
30
+ - name: Verify tag matches package version
31
+ if: startsWith(github.ref, 'refs/tags/')
32
+ run: |
33
+ TAG_VERSION="${GITHUB_REF_NAME#v}"
34
+ PACKAGE_VERSION="$(python - <<'PY'
35
+ from pathlib import Path
36
+ import re
37
+
38
+ text = Path("src/urlscope/__init__.py").read_text()
39
+ match = re.search(r'^__version__\s*=\s*["\']([^"\']+)["\']', text, re.MULTILINE)
40
+ if match is None:
41
+ raise SystemExit("Could not find __version__ in src/urlscope/__init__.py")
42
+ print(match.group(1))
43
+ PY
44
+ )"
45
+
46
+ if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
47
+ echo "Tag version ($TAG_VERSION) does not match package version ($PACKAGE_VERSION)."
48
+ exit 1
49
+ fi
50
+
51
+ - name: Build distributions
52
+ run: uv build
53
+
54
+ - name: Validate distributions
55
+ run: uvx twine check dist/*
56
+
57
+ - name: Publish to PyPI
58
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,60 @@
1
+ name: Publish to TestPyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "test-v*"
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ publish:
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ id-token: write
14
+
15
+ steps:
16
+ - name: Check out repository
17
+ uses: actions/checkout@v6
18
+
19
+ - name: Set up uv
20
+ uses: astral-sh/setup-uv@v7
21
+ with:
22
+ enable-cache: true
23
+ cache-dependency-glob: pyproject.toml
24
+
25
+ - name: Set up Python
26
+ uses: actions/setup-python@v6
27
+ with:
28
+ python-version: "3.11"
29
+
30
+ - name: Verify tag matches package version
31
+ if: startsWith(github.ref, 'refs/tags/')
32
+ run: |
33
+ TAG_VERSION="${GITHUB_REF_NAME#test-v}"
34
+ PACKAGE_VERSION="$(python - <<'PY'
35
+ from pathlib import Path
36
+ import re
37
+
38
+ text = Path("src/urlscope/__init__.py").read_text()
39
+ match = re.search(r'^__version__\s*=\s*["\']([^"\']+)["\']', text, re.MULTILINE)
40
+ if match is None:
41
+ raise SystemExit("Could not find __version__ in src/urlscope/__init__.py")
42
+ print(match.group(1))
43
+ PY
44
+ )"
45
+
46
+ if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
47
+ echo "Tag version ($TAG_VERSION) does not match package version ($PACKAGE_VERSION)."
48
+ exit 1
49
+ fi
50
+
51
+ - name: Build distributions
52
+ run: uv build
53
+
54
+ - name: Validate distributions
55
+ run: uvx twine check dist/*
56
+
57
+ - name: Publish to TestPyPI
58
+ uses: pypa/gh-action-pypi-publish@release/v1
59
+ with:
60
+ repository-url: https://test.pypi.org/legacy/
@@ -0,0 +1,59 @@
1
+ name: Release Build
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - name: Check out repository
15
+ uses: actions/checkout@v6
16
+
17
+ - name: Set up uv
18
+ uses: astral-sh/setup-uv@v7
19
+ with:
20
+ enable-cache: true
21
+ cache-dependency-glob: pyproject.toml
22
+
23
+ - name: Set up Python
24
+ uses: actions/setup-python@v6
25
+ with:
26
+ python-version: "3.11"
27
+
28
+ - name: Verify tag matches package version
29
+ if: startsWith(github.ref, 'refs/tags/')
30
+ run: |
31
+ TAG_VERSION="${GITHUB_REF_NAME#v}"
32
+ PACKAGE_VERSION="$(python - <<'PY'
33
+ from pathlib import Path
34
+ import re
35
+
36
+ text = Path("src/urlscope/__init__.py").read_text()
37
+ match = re.search(r'^__version__\s*=\s*["\']([^"\']+)["\']', text, re.MULTILINE)
38
+ if match is None:
39
+ raise SystemExit("Could not find __version__ in src/urlscope/__init__.py")
40
+ print(match.group(1))
41
+ PY
42
+ )"
43
+
44
+ if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
45
+ echo "Tag version ($TAG_VERSION) does not match package version ($PACKAGE_VERSION)."
46
+ exit 1
47
+ fi
48
+
49
+ - name: Build distributions
50
+ run: uv build
51
+
52
+ - name: Validate distributions
53
+ run: uvx twine check dist/*
54
+
55
+ - name: Upload build artifacts
56
+ uses: actions/upload-artifact@v4
57
+ with:
58
+ name: dist-${{ github.ref_name || github.run_id }}
59
+ path: dist/
@@ -0,0 +1,247 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
208
+
209
+
210
+
211
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
212
+
213
+
214
+ # --------------- Environments ---------------
215
+
216
+ .env
217
+ .envrc
218
+ .env.local
219
+ env/
220
+ ENV/
221
+ env.bak/
222
+
223
+ # --------------- AI -------------------------
224
+
225
+ # Aider
226
+ .aider.conf.yml
227
+ .aider*
228
+
229
+ # Claude Code - personal/session files only
230
+ .claude/settings.local.json
231
+ .claude/*.log
232
+ .claude/logs/
233
+ .claude/cache/
234
+
235
+ # OpenCode - session data and local files
236
+ .opencode/
237
+
238
+ # Gemini CLI - project-level config dir (session data in ~/.gemini/)
239
+ # NOTE: commit .gemini/settings.json explicitly if sharing with team
240
+ .gemini/
241
+
242
+ # Codex CLI - project-level config (session data, history, logs in ~/.codex/)
243
+ # NOTE: commit .codex/config.toml explicitly if sharing with team
244
+ .codex/
245
+
246
+ # Cursor - nothing needed (all data in ~/.config/Cursor/ or ~/.cursor/)
247
+ # Optional: .cursorignore if you want to control AI context (safe to commit)
@@ -0,0 +1,44 @@
1
+ # Repository Guidelines
2
+
3
+ ## Project Structure & Module Organization
4
+
5
+ This repository uses a `src/` layout for the `urlscope` Python package. Core implementation lives in `src/urlscope/`: `_client.py` for the async client, `_sync.py` for the sync wrapper, `_http.py` for transport/auth/retry behavior, `_exceptions.py` for the exception hierarchy, and `models/` for Pydantic response models (`_submission.py`, `_result.py`, `_search.py`, `_quota.py`). Tests live in `tests/`, with shared fixtures in `tests/conftest.py`. Product requirements and task sequencing live under `specs/001-urlscan-api-wrapper/`; treat those documents as the source of truth, but verify against the live urlscan API when behavior appears to drift.
6
+
7
+ ## Build, Test, and Development Commands
8
+
9
+ Use the managed virtual environment:
10
+
11
+ ```bash
12
+ uv sync --extra dev
13
+ .venv/bin/python -c "import urlscope"
14
+ .venv/bin/pytest tests/
15
+ .venv/bin/ruff check src/ tests/
16
+ .venv/bin/mypy src/
17
+ ```
18
+
19
+ `uv sync --extra dev` installs runtime and dev dependencies into `.venv`. The import check confirms packaging works. Run `pytest` for tests, `ruff` for linting, and `mypy` in strict mode before opening a PR.
20
+
21
+ ## Coding Style & Naming Conventions
22
+
23
+ Target Python 3.10+ and keep type annotations complete. Use `snake_case` for modules, functions, and variables, `PascalCase` for classes, and `_`-prefixed module names for internal implementation details. Keep public exports centralized in `src/urlscope/__init__.py`. For models, preserve upstream JSON compatibility with Pydantic aliases for camelCase fields such as `apexDomain -> apex_domain`. When the live API shape differs from the local spec, update the spec docs and tests together instead of carrying silent compatibility hacks.
24
+
25
+ ## Testing Guidelines
26
+
27
+ Use `pytest`, `pytest-asyncio`, and `respx` for async and HTTP transport tests. Name files by feature area, for example `tests/test_submit.py` or `tests/test_errors.py`. Prefer shared fixtures from `tests/conftest.py` over inline sample payloads. The current suite covers async and sync client behavior, search pagination, artifacts, quota handling, retry logic, and context management. Run focused files while iterating, then rerun the affected area after any live-API-driven fix. Avoid brittle assertions based on `id()` or other runtime reuse details when a direct object or value assertion is possible.
28
+
29
+ ## Live API Drift
30
+
31
+ Treat mocked tests as the default, but use live smoke tests to validate behavior that may have changed upstream. When the real urlscan API contradicts the local spec, update implementation, tests, and spec docs together instead of leaving the mismatch undocumented. Known live-API corrections in this repo:
32
+
33
+ - Search pagination requires `search_after` as one comma-separated string, not repeated query parameters.
34
+ - Quotas come from `GET /api/v1/quotas`, and the live response is nested under `limits`. The library preserves raw `limits` and exposes a flattened `QuotaInfo.quotas` convenience view.
35
+
36
+ Keep live smoke tests small and explicit, and avoid turning them into default test-suite requirements.
37
+
38
+ ## Commit & Pull Request Guidelines
39
+
40
+ Write short, imperative commit subjects such as `Add result polling tests`. Keep commits scoped to a single task or coherent change. Recent history follows task-based commits and occasional follow-up fixes for live API mismatches; continuing that pattern is preferred. PRs should include a concise summary, references to the relevant spec/task IDs, and the exact verification commands you ran, including live smoke tests when they drove a behavior change.
41
+
42
+ ## Security & Configuration Tips
43
+
44
+ Never commit real API keys. Use `URLSCAN_API_KEY` for local development or pass credentials explicitly at runtime. Keep fixtures and examples sanitized, and avoid checking in captured scan artifacts or sensitive response payloads.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jan Wychowaniak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.