Skip to content

Commit 5787acc

Browse files
authored
PYTHON-5556 Keep uv lock file up to date (mongodb#2534)
1 parent 4b4d749 commit 5787acc

File tree

6 files changed

+67
-53
lines changed

6 files changed

+67
-53
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ repos:
105105
# - test/test_client.py:188: te ==> the, be, we, to
106106
args: ["-L", "fle,fo,infinit,isnt,nin,te,aks"]
107107

108+
- repo: https://github.com/astral-sh/uv-pre-commit
109+
# uv version.
110+
rev: 0.8.17
111+
hooks:
112+
- id: uv-lock
113+
108114
- repo: local
109115
hooks:
110116
- id: executable-shell

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,3 +514,11 @@ To profile a test script and generate a flame graph, follow these steps:
514514
(Note: on macOS you will need to run this command using `sudo` to allow `py-spy` to attach to the Python process.)
515515
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`.
516516
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.
517+
518+
## Dependabot updates
519+
520+
Dependabot will raise PRs at most once per week, grouped by GitHub Actions updates and Python requirement
521+
file updates. We have a pre-commit hook that will update the `uv.lock` file when requirements change.
522+
To update the lock file on a failing PR, you can use a method like `gh pr checkout <pr number>`, then run
523+
`just lint uv-lock` to update the lock file, and then push the changes. If a typing dependency has changed,
524+
also run `just typing` and handle any new findings.

bson/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ def decode_iter(
13271327
elements = data[position : position + obj_size]
13281328
position += obj_size
13291329

1330-
yield _bson_to_dict(elements, opts) # type:ignore[misc]
1330+
yield _bson_to_dict(elements, opts)
13311331

13321332

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

13781378

13791379
def is_valid(bson: bytes) -> bool:

justfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ typing-pyright: && resync
5050
{{typing_run}} pyright -p strict_pyrightconfig.json test/test_typing_strict.py
5151

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

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

6060
[group('test')]
6161
test *args="-v --durations=5 --maxfail=10": && resync

test/test_typing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def test_bulk_write_heterogeneous(self):
170170
InsertOne(Movie(name="American Graffiti", year=1973)),
171171
ReplaceOne(
172172
{},
173-
{"name": "American Graffiti", "year": "WRONG_TYPE"}, # type:ignore[typeddict-item]
173+
{"name": "American Graffiti", "year": "WRONG_TYPE"}, # type:ignore[arg-type]
174174
),
175175
DeleteOne({}),
176176
]
@@ -243,7 +243,7 @@ def test_with_options(self) -> None:
243243
assert retrieved is not None
244244
assert retrieved["name"] == "foo"
245245
# We expect a type error here.
246-
assert retrieved["other"] == 1 # type:ignore[typeddict-item]
246+
assert retrieved["other"] == 1 # type:ignore[misc]
247247

248248

249249
class TestDecode(unittest.TestCase):
@@ -416,11 +416,11 @@ def test_typeddict_document_type_insertion(self) -> None:
416416
bad_mov = {"name": "THX-1138", "year": "WRONG TYPE"}
417417
bad_movie = Movie(name="THX-1138", year="WRONG TYPE") # type: ignore[typeddict-item]
418418
coll.insert_one(bad_mov) # type:ignore[arg-type]
419-
coll.insert_one({"name": "THX-1138", "year": "WRONG TYPE"}) # type: ignore[typeddict-item]
419+
coll.insert_one({"name": "THX-1138", "year": "WRONG TYPE"}) # type: ignore[arg-type]
420420
coll.insert_one(bad_movie)
421421
coll.insert_many([bad_mov]) # type: ignore[list-item]
422422
coll.insert_many(
423-
[{"name": "THX-1138", "year": "WRONG TYPE"}] # type: ignore[typeddict-item]
423+
[{"name": "THX-1138", "year": "WRONG TYPE"}] # type: ignore[list-item]
424424
)
425425
coll.insert_many([bad_movie])
426426

0 commit comments

Comments
 (0)