Skip to content

Commit ada72df

Browse files
authored
ratchet(types): promote no-matching-overload to error (#1293)
1 parent 1f0c869 commit ada72df

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

core/schemas/observable.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
import tempfile
77
from enum import Enum
8-
from typing import IO, ClassVar, List, Literal, Tuple, Union
8+
from typing import IO, ClassVar, List, Literal, Tuple, Union, cast
99

1010
import requests
1111
from bs4 import BeautifulSoup
@@ -183,7 +183,9 @@ def create_from_file(file: FileLikeObject) -> Tuple[List["ObservableTypes"], Lis
183183
"""
184184
opened = False
185185
if isinstance(file, (str, bytes, os.PathLike)):
186-
f = open(file, "r", encoding="utf-8")
186+
# The isinstance guard narrows `file` to a path, but FileLikeObject's
187+
# unparametrized os.PathLike doesn't match open()'s PathLike[str] overload.
188+
f = open(cast("str | os.PathLike[str]", file), "r", encoding="utf-8")
187189
opened = True
188190
elif isinstance(file, (io.IOBase, tempfile.SpooledTemporaryFile)):
189191
f = file

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ invalid-method-override = "warn" # 8
9494
call-non-callable = "warn" # 7
9595
invalid-type-form = "warn" # 5 — pydantic conlist() in annotations
9696
unresolved-import = "warn" # 3 — optional deps not present in lint env
97-
no-matching-overload = "warn" # 1
97+
no-matching-overload = "error" # 0 — cast the isinstance-narrowed path for open()
9898
missing-argument = "warn" # 1
9999
unknown-argument = "error" # 0 — fixed a stray strict= kwarg on cls.load
100100

0 commit comments

Comments
 (0)