diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..3b3155c --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,15 @@ +{ + "hooks": { + "PostToolUse": [ + { + "matcher": "Write|Edit|MultiEdit", + "hooks": [ + { + "type": "command", + "command": "jq -r .tool_input.file_path | { read file_path; if echo \"$file_path\" | grep -qE \"\\.(py)$\"; then scripts/lint.sh \"$file_path\"; fi; }" + } + ] + } + ] + } +} diff --git a/poetry.lock b/poetry.lock index 4414d06..6c3963d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -613,6 +613,21 @@ files = [ {file = "tomli-2.2.1.tar.gz", hash = "sha256:cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff"}, ] +[[package]] +name = "types-requests" +version = "2.32.4.20250913" +description = "Typing stubs for requests" +optional = false +python-versions = ">=3.9" +groups = ["dev"] +files = [ + {file = "types_requests-2.32.4.20250913-py3-none-any.whl", hash = "sha256:78c9c1fffebbe0fa487a418e0fa5252017e9c60d1a2da394077f1780f655d7e1"}, + {file = "types_requests-2.32.4.20250913.tar.gz", hash = "sha256:abd6d4f9ce3a9383f269775a9835a4c24e5cd6b9f647d64f88aa4613c33def5d"}, +] + +[package.dependencies] +urllib3 = ">=2" + [[package]] name = "typing-extensions" version = "4.14.0" @@ -646,7 +661,7 @@ version = "2.5.0" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.9" -groups = ["main"] +groups = ["main", "dev"] files = [ {file = "urllib3-2.5.0-py3-none-any.whl", hash = "sha256:e6b01673c0fa6a13e374b50871808eb3bf7046c4b125b216f6bf1cc604cff0dc"}, {file = "urllib3-2.5.0.tar.gz", hash = "sha256:3fc47733c7e419d4bc3f6b3dc2b4f890bb743906a30d56ba4a5bfa4bbff92760"}, @@ -661,4 +676,4 @@ zstd = ["zstandard (>=0.18.0)"] [metadata] lock-version = "2.1" python-versions = ">=3.10" -content-hash = "b286a33795fe9f764f5da9cc1b9569bd5100251997017f8e85ebc67261707f59" +content-hash = "8dbdd73c071b243cdffd7f2f8117e01aeb55f4cc4b19ee5b009c24668e6aa2b1" diff --git a/pyproject.toml b/pyproject.toml index 86d04b1..963a212 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,7 @@ packages = [{ include = "cvec", from = "src" }] pytest = "^8.3.5" mypy = "^1.15.0" ruff = "^0.11.10" +types-requests = "^2.32.0" [build-system] requires = ["poetry-core>=2.0.0,<3.0.0"] diff --git a/scripts/csv_import.py b/scripts/csv_import.py index d79297e..f6dc45e 100755 --- a/scripts/csv_import.py +++ b/scripts/csv_import.py @@ -12,6 +12,7 @@ from datetime import datetime from pathlib import Path from typing import List, Optional +import requests from cvec import CVec from cvec.models.metric import MetricDataPoint @@ -30,6 +31,7 @@ def parse_timestamp(timestamp_str: str) -> datetime: "%Y-%m-%d", "%m/%d/%Y %H:%M:%S", "%m/%d/%Y", + "%m/%d/%y %H:%M", ] for fmt in formats: @@ -209,6 +211,14 @@ def main() -> None: metric_prefix=args.prefix, ) + except requests.HTTPError as e: + print(f"Error: {e}") + # Display CloudFront ID if available + if e.response is not None: + cf_id = e.response.headers.get("x-amz-cf-id") + if cf_id: + print(f"Cf-Id: {cf_id}") + sys.exit(1) except Exception as e: print(f"Error: {e}") sys.exit(1) diff --git a/scripts/lint.sh b/scripts/lint.sh index ae674b4..c42c710 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -6,6 +6,14 @@ set -e TARGET=${1:-.} -poetry run ruff check --fix "$TARGET" -poetry run ruff format "$TARGET" -poetry run mypy --strict "$TARGET" +echo -e "poetry run ruff check --fix" "$@" +poetry run ruff check --fix "$@" + +echo -e "\npoetry run ruff format" "$@" +poetry run ruff format "$@" + +echo -e "\nrun mypy --strict" "$@" +poetry run mypy --strict "$@" + +echo -e "\npoetry run pytest" +poetry run pytest diff --git a/src/cvec/cvec.py b/src/cvec/cvec.py index ec37f92..f5e9fd9 100644 --- a/src/cvec/cvec.py +++ b/src/cvec/cvec.py @@ -3,7 +3,7 @@ from typing import Any, Dict, List, Optional from urllib.parse import urljoin -import requests # type: ignore[import-untyped] +import requests from cvec.models.metric import Metric, MetricDataPoint from cvec.models.span import Span