mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
ifcopenshell.open overload signature to consider new readonly argument
This commit is contained in:
@@ -135,7 +135,7 @@ def open(
|
||||
def open(path: Union[os.PathLike, str], format: Optional[str] = None, *, should_stream: Literal[True]) -> _stream: ...
|
||||
@overload
|
||||
def open(
|
||||
path: Union[os.PathLike, str], format: Optional[str] = None, *, should_stream: bool
|
||||
path: Union[os.PathLike, str], format: Optional[str] = None, *, should_stream: bool = False, readonly: bool = False
|
||||
) -> Union[_file, sqlite, _stream]: ...
|
||||
def open(
|
||||
path: Union[os.PathLike, str], format: Optional[str] = None, should_stream: bool = False, readonly: bool = False
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
# IfcOpenShell - IFC toolkit and geometry engine
|
||||
# Copyright (C) 2021 Thomas Krijnen <thomas@aecgeeks.com>
|
||||
#
|
||||
# This file is part of IfcOpenShell.
|
||||
#
|
||||
# IfcOpenShell is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# IfcOpenShell is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""Typing tests for ifcopenshell.
|
||||
|
||||
This file should produce no warnings from type checker (currently pyright).
|
||||
Those tests are not automatically checked and just there to make sure overloads are making sense.
|
||||
"""
|
||||
|
||||
|
||||
import ifcopenshell
|
||||
from typing import assert_type, Union
|
||||
|
||||
|
||||
def ifcopenshell_open_test(str_: str, bool_: bool):
|
||||
ifc_file = ifcopenshell.open(str_)
|
||||
assert_type(ifc_file, Union[ifcopenshell.file, ifcopenshell.sqlite])
|
||||
|
||||
ifc_file = ifcopenshell.open(str_, should_stream=bool_)
|
||||
assert_type(ifc_file, Union[ifcopenshell.file, ifcopenshell.sqlite, ifcopenshell.stream])
|
||||
|
||||
ifc_file = ifcopenshell.open(str_, should_stream=True)
|
||||
assert_type(ifc_file, ifcopenshell.stream)
|
||||
|
||||
ifc_file = ifcopenshell.open(str_, readonly=True)
|
||||
Reference in New Issue
Block a user