Skip to content

Commit 86bef0a

Browse files
committed
typing
1 parent 05bf59d commit 86bef0a

3 files changed

Lines changed: 18 additions & 16 deletions

File tree

src/bonsai/bonsai/bim/module/project/operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ def load_handler(*args):
11021102
else:
11031103
return self.finish_loading_project(context)
11041104

1105-
def finish_loading_project(self, context):
1105+
def finish_loading_project(self, context: bpy.types.Context) -> set["rna_enums.OperatorReturnItems"]:
11061106
try:
11071107
filepath = self.get_filepath()
11081108
if not self.is_existing_ifc_file():

src/ifcopenshell-python/ifcopenshell/__init__.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,17 @@ class SchemaError(Error):
131131

132132
@overload
133133
def open(
134-
path: Union[os.PathLike, str], format: Optional[str] = None, *, should_stream: Literal[False] = False
134+
path: Union[os.PathLike, str], format: SupportedFormat = None, *, should_stream: Literal[False] = False
135135
) -> Union[_file, sqlite]: ...
136136
@overload
137-
def open(path: Union[os.PathLike, str], format: Optional[str] = None, *, should_stream: Literal[True]) -> _stream: ...
137+
def open(path: Union[os.PathLike, str], format: SupportedFormat = None, *, should_stream: Literal[True]) -> _stream: ...
138138
@overload
139139
def open(
140-
path: Union[os.PathLike, str], format: Optional[str] = None, *, should_stream: bool = False, readonly: bool = False
140+
path: Union[os.PathLike, str], format: SupportedFormat = None, *, should_stream: bool = False, readonly: bool = False
141141
) -> Union[_file, sqlite, _stream]: ...
142142
def open(
143143
path: Union[os.PathLike, str],
144-
format: Optional[str] = None,
144+
format: SupportedFormat = None,
145145
should_stream: bool = False,
146146
readonly: bool = False,
147147
mmap: bool = False,
@@ -153,8 +153,7 @@ def open(
153153
for reading large files.
154154
155155
You can specify a file format. If no format is given, it is guessed from
156-
its extension. Currently supported specified format: .ifc | .ifcZIP |
157-
.ifcXML.
156+
its extension.
158157
159158
You can then filter by element ID, class, etc, and subscript by id or guid.
160159
@@ -200,12 +199,12 @@ def open(
200199
f.bypass_type(ty)
201200
if mmap:
202201
# mmap parameter is only available for builds with USE_MMAP, not used in our main builds
203-
f.initialize(str(path.absolute()), mmap=mmap) # type: ignore[unknown-argument]
202+
f.initialize(str(path.absolute()), mmap=mmap) # ty: ignore[unknown-argument]
204203
else:
205204
f.initialize(str(path.absolute()))
206205
elif mmap:
207206
# mmap parameter is only available for builds with USE_MMAP, not used in our main builds
208-
f = ifcopenshell_wrapper.open(str(path.absolute()), mmap=mmap) # type: ignore[unknown-argument]
207+
f = ifcopenshell_wrapper.open(str(path.absolute()), mmap=mmap) # ty: ignore[unknown-argument]
209208
else:
210209
f = ifcopenshell_wrapper.open(str(path.absolute()))
211210
return file(f)
@@ -288,7 +287,10 @@ def schema_by_name(
288287
return ifcopenshell_wrapper.schema_by_name(schema)
289288

290289

291-
def guess_format(path: Path) -> Literal[".ifc", ".ifcZIP", ".ifcXML", ".ifcJSON", ".ifcSQLite", None]:
290+
SupportedFormat = Literal[".ifc", ".ifcZIP", ".ifcXML", ".ifcJSON", ".ifcSQLite", "rocksdb", None]
291+
292+
293+
def guess_format(path: Path) -> SupportedFormat:
292294
"""Guesses the IFC format using file extension
293295
294296
IFCs may be serialised as different formats. The most common is a ``.ifc``

src/ifcopenshell-python/ifcopenshell/ifcopenshell_wrapper.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,10 @@ class RocksDBPrefixIterator:
434434

435435
class RocksDbSerializer:
436436
def __init__(self, *args): ...
437-
def finalize(self): ...
438-
def ready(self): ...
439-
def setFile(self, arg2): ...
440-
def writeHeader(self): ...
437+
def finalize(self) -> None: ...
438+
def ready(self) -> bool: ...
439+
def setFile(self, arg2) -> None: ...
440+
def writeHeader(self) -> None: ...
441441

442442
class Serialization(Representation):
443443
def __init__(self, brep): ...
@@ -1008,7 +1008,7 @@ class file:
10081008
def by_id(self, id: int) -> entity_instance: ...
10091009
def by_type(self, *args): ...
10101010
def by_type_excl_subtypes(self, *args): ...
1011-
def bypass_type(self, type_name): ...
1011+
def bypass_type(self, type_name: str) -> None: ...
10121012
calculate_unit_factors: bool
10131013
check_existance_before_adding: bool
10141014
def create(self, decl): ...
@@ -1717,7 +1717,7 @@ def line_segments_to_polygons(s, eps, segments): ...
17171717
def map_shape(settings, instance): ...
17181718
def nary_union(sequence): ...
17191719
def new_IfcBaseClass(schema_identifier: str, name: str) -> entity_instance: ...
1720-
def open(fn, readonly=False): ...
1720+
def open(fn: str, readonly: bool = False) -> file: ...
17211721
def parse_ifcxml(filename): ...
17221722
def polygons_to_svg(*args): ...
17231723
def read(data): ...

0 commit comments

Comments
 (0)