Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Type check

on: [pull_request]

jobs:
pyrefly:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: poetry
- name: Install Python dependencies
run: poetry install --no-root
- name: Type check with pyrefly
run: poetry run pyrefly check
40 changes: 36 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ requests-toolbelt = "^1.0.0"

[tool.poetry.group.dev.dependencies]
ruff = "^0.8.3"
pyrefly = "^1.2.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.pyrefly]
project-includes = ["yeti"]
project-excludes = ["tests"]
16 changes: 8 additions & 8 deletions yeti/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def do_request(
if json_data and body:
raise ValueError("You must provide either json or body, not both.")

request_kwargs = {}
request_kwargs: dict[str, Any] = {}

if headers:
request_kwargs["headers"] = headers
Expand Down Expand Up @@ -241,7 +241,7 @@ def search_indicators(
"You must provide one of name, indicator_type, pattern, description, or tags."
)

query = {}
query: dict[str, Any] = {}
if name:
query["name"] = name
if pattern:
Expand Down Expand Up @@ -328,7 +328,7 @@ def search_entities(
if not any([name, entity_type, description]):
raise ValueError("You must provide one of name, type, or description.")

query = {}
query: dict[str, Any] = {}
if name:
query["name"] = name
if entity_type:
Expand Down Expand Up @@ -448,7 +448,7 @@ def search_observables(
Returns:
The response from the API; a dict representing the observable.
"""
query = {"value": value}
query: dict[str, Any] = {"value": value}
if tags:
query["tags"] = tags
params = {"query": query, "count": count, "page": page}
Expand Down Expand Up @@ -526,7 +526,7 @@ def new_entity(
Returns:
The response from the API; a dict representing the entity.
"""
params = {"entity": entity}
params: dict[str, Any] = {"entity": entity}
if tags:
params["tags"] = tags
response = self.do_request(
Expand Down Expand Up @@ -660,7 +660,7 @@ def search_dfiq(
Returns:
The response from the API; a dict representing the DFIQ object.
"""
query = {
query: dict[str, Any] = {
"name": name,
}

Expand All @@ -669,7 +669,7 @@ def search_dfiq(
if dfiq_tags:
query["dfiq_tags"] = dfiq_tags

params = {
params: dict[str, Any] = {
"query": query,
"count": count,
"page": page,
Expand Down Expand Up @@ -751,7 +751,7 @@ def download_dfiq_archive(self, dfiq_type: str | None = None) -> bytes:
Returns:
The archive contents as bytes.
"""
params = {"count": 0}
params: dict[str, Any] = {"count": 0}
if dfiq_type:
params["query"] = {"type": dfiq_type}
response = self.do_request(
Expand Down
Loading