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
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ repos:
# - test/test_client.py:188: te ==> the, be, we, to
args: ["-L", "fle,fo,infinit,isnt,nin,te,aks"]

- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.8.17
hooks:
- id: uv-lock

- repo: local
hooks:
- id: executable-shell
Expand Down
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -514,3 +514,11 @@ To profile a test script and generate a flame graph, follow these steps:
(Note: on macOS you will need to run this command using `sudo` to allow `py-spy` to attach to the Python process.)
4. If you need to include native code (for example the C extensions), profiling should be done on a Linux system, as macOS and Windows do not support the `--native` option of `py-spy`.
Creating an ubuntu Evergreen spawn host and using `scp` to copy the flamegraph `.svg` file back to your local machine is the best way to do this.

## Dependabot updates

Dependabot will raise PRs at most once per week, grouped by GitHub Actions updates and Python requirement
file updates. We have a pre-commit hook that will update the `uv.lock` file when requirements change.
To update the lock file on a failing PR, you can use a method like `gh pr checkout <pr number>`, then run
`just lint uv-lock` to update the lock file, and then push the changes. If a typing dependency has changed,
also run `just typing` and handle any new findings.
4 changes: 2 additions & 2 deletions bson/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ def decode_iter(
elements = data[position : position + obj_size]
position += obj_size

yield _bson_to_dict(elements, opts) # type:ignore[misc]
yield _bson_to_dict(elements, opts)


@overload
Expand Down Expand Up @@ -1373,7 +1373,7 @@ def decode_file_iter(
raise InvalidBSON("cut off in middle of objsize")
obj_size = _UNPACK_INT_FROM(size_data, 0)[0] - 4
elements = size_data + file_obj.read(max(0, obj_size))
yield _bson_to_dict(elements, opts) # type:ignore[arg-type, misc]
yield _bson_to_dict(elements, opts) # type:ignore[misc]


def is_valid(bson: bytes) -> bool:
Expand Down
8 changes: 4 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ typing-pyright: && resync
{{typing_run}} pyright -p strict_pyrightconfig.json test/test_typing_strict.py

[group('lint')]
lint: && resync
uv run pre-commit run --all-files
lint *args="": && resync
uv run pre-commit run --all-files {{args}}

[group('lint')]
lint-manual: && resync
uv run pre-commit run --all-files --hook-stage manual
lint-manual *args="": && resync
uv run pre-commit run --all-files --hook-stage manual {{args}}

[group('test')]
test *args="-v --durations=5 --maxfail=10": && resync
Expand Down
8 changes: 4 additions & 4 deletions test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def test_bulk_write_heterogeneous(self):
InsertOne(Movie(name="American Graffiti", year=1973)),
ReplaceOne(
{},
{"name": "American Graffiti", "year": "WRONG_TYPE"}, # type:ignore[typeddict-item]
{"name": "American Graffiti", "year": "WRONG_TYPE"}, # type:ignore[arg-type]
),
DeleteOne({}),
]
Expand Down Expand Up @@ -243,7 +243,7 @@ def test_with_options(self) -> None:
assert retrieved is not None
assert retrieved["name"] == "foo"
# We expect a type error here.
assert retrieved["other"] == 1 # type:ignore[typeddict-item]
assert retrieved["other"] == 1 # type:ignore[misc]


class TestDecode(unittest.TestCase):
Expand Down Expand Up @@ -416,11 +416,11 @@ def test_typeddict_document_type_insertion(self) -> None:
bad_mov = {"name": "THX-1138", "year": "WRONG TYPE"}
bad_movie = Movie(name="THX-1138", year="WRONG TYPE") # type: ignore[typeddict-item]
coll.insert_one(bad_mov) # type:ignore[arg-type]
coll.insert_one({"name": "THX-1138", "year": "WRONG TYPE"}) # type: ignore[typeddict-item]
coll.insert_one({"name": "THX-1138", "year": "WRONG TYPE"}) # type: ignore[arg-type]
coll.insert_one(bad_movie)
coll.insert_many([bad_mov]) # type: ignore[list-item]
coll.insert_many(
[{"name": "THX-1138", "year": "WRONG TYPE"}] # type: ignore[typeddict-item]
[{"name": "THX-1138", "year": "WRONG TYPE"}] # type: ignore[list-item]
)
coll.insert_many([bad_movie])

Expand Down
Loading
Loading