Skip to content

Commit 838306f

Browse files
committed
address typing
1 parent 8b7accd commit 838306f

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,4 +520,5 @@ To profile a test script and generate a flame graph, follow these steps:
520520
Dependabot will raise PRs at most once per week, grouped by GitHub Actions updates and Python requirement
521521
file updates. We have a pre-commit hook that will update the `uv.lock` file when requirements change.
522522
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.
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:

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)