-
Notifications
You must be signed in to change notification settings - Fork 205
Raise error when sending credentials over HTTP #593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # CLAUDE.md | ||
|
|
||
| ## Common Commands | ||
|
|
||
| ```bash | ||
| # Setup | ||
| python3 -m venv .venv && . .venv/bin/activate | ||
| pip install -e '.[tests]' | ||
|
|
||
| # Run unit tests | ||
| pytest tests/unit | ||
|
|
||
| # Run a single test | ||
| pytest tests/unit/test_client.py::test_name -sv | ||
|
|
||
| # Run integration tests (starts a Trino Docker container automatically, or uses an existing one on localhost:8080) | ||
| pytest tests/integration | ||
|
|
||
| # Start a standalone Trino (+ LocalStack) dev server for manual testing, without pytest | ||
| python tests/development_server.py | ||
|
|
||
| # Lint and format checks | ||
| pre-commit run --all-files | ||
|
|
||
| # Type checking only | ||
| mypy trino/ | ||
|
|
||
| # Run tests across all supported Python versions | ||
| tox | ||
| ``` | ||
|
|
||
| ## Architecture | ||
|
|
||
| ### Package layout (`trino/`) | ||
|
|
||
| - **`client.py`** - Core HTTP protocol implementation. `TrinoRequest` manages HTTP requests to the coordinator, `TrinoQuery` manages query lifecycle (submit -> poll -> fetch results), `ClientSession` holds connection state (headers, session properties, transaction ID). Implements the protocol described at https://github.com/trinodb/trino/wiki/HTTP-Protocol. | ||
| - **`dbapi.py`** - PEP 249 DBAPI 2.0 interface. `Connection` and `Cursor` classes that wrap `client.py`. Entry point is `trino.dbapi.connect()`. | ||
| - **`sqlalchemy/`** - SQLAlchemy dialect (`TrinoDialect`), compiler, and type mapping. Registered as `trino://` via `sqlalchemy.dialects` entry point. Compatible with SQLAlchemy 1.3.x, 1.4.x, and 2.0.x. | ||
| - **`auth.py`** - Authentication implementations (Basic, JWT, OAuth2, Kerberos/GSSAPI, Certificate). | ||
| - **`types.py`** - Python representations of Trino SQL types. | ||
| - **`mapper.py`** - Conversion between Trino wire types and Python objects. | ||
| - **`transaction.py`** - Transaction and isolation level management. | ||
| - **`exceptions.py`** - Exception hierarchy following DBAPI 2.0 spec. | ||
| - **`constants.py`** - Protocol header names and type metadata constants. | ||
| - **`logging.py`** - Logger factory used across the package. | ||
|
|
||
| ### Tests (`tests/`) | ||
|
|
||
| - `tests/unit/` - No external dependencies needed. Uses `httpretty` for HTTP mocking. | ||
| - `tests/integration/` - Requires Docker. Tests automatically pull `trinodb/trino` image and start a container (or reuse one on port 8080). | ||
| - Env vars: `TRINO_VERSION` (image tag, default `latest`), `TRINO_RUNNING_HOST`/`TRINO_RUNNING_PORT` (use an existing server instead of starting one). | ||
| - When `TRINO_VERSION` is `latest` or >= 466, a LocalStack container with an S3 `spooling` bucket is also started to test the spooled client protocol; older versions use the `etc/*-pre-466*` configs. | ||
|
|
||
| ### Key dependencies | ||
|
|
||
| - `requests` - HTTP transport | ||
| - `orjson` (CPython) / `json` (PyPy) - JSON parsing, selected at import time in `client.py` | ||
| - `lz4`, `zstandard` - Response decompression | ||
| - `python-dateutil`, `pytz`, `tzlocal` - Timezone/datetime handling | ||
|
|
||
| ## Code Style | ||
|
|
||
| - **Max line length**: 120 characters (flake8) | ||
| - **Import ordering**: managed by `reorder-python-imports` (Python 3.9+ style) | ||
| - **Type checking**: mypy with strict settings, though `tests/*`, `trino/client`, `trino/dbapi`, and `trino/sqlalchemy.*` have `ignore_errors = true` | ||
| - **No mocking libraries**: write mocks by hand instead of using `unittest.mock` or similar. The project uses `httpretty` for HTTP-level stubbing only. | ||
| - **Pre-commit hooks**: flake8, mypy, reorder-python-imports, trailing whitespace, EOF newlines, YAML syntax, case-conflict checks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.