Skip to content
This repository was archived by the owner on Nov 24, 2024. It is now read-only.

Commit ebd03e9

Browse files
committed
typing
1 parent c3bfd73 commit ebd03e9

56 files changed

Lines changed: 244 additions & 127 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/ifcopenshell-python/ifcopenshell/api/layer/add_layer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
#
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
18+
import ifcopenshell
19+
from typing import Optional
1820

1921

20-
def add_layer(file, Name=None) -> None:
22+
def add_layer(file: ifcopenshell.file, Name: Optional[str] = None) -> ifcopenshell.entity_instance:
2123
"""Adds a new layer
2224
2325
An IFC layer is like a CAD layer. Portions of an object's geometry
@@ -41,6 +43,4 @@ def add_layer(file, Name=None) -> None:
4143
4244
ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL-FULL-DIMS-N")
4345
"""
44-
settings = {"Name": Name or "Unnamed"}
45-
46-
return file.create_entity("IfcPresentationLayerAssignment", Name=settings["Name"])
46+
return file.create_entity("IfcPresentationLayerAssignment", Name=Name)

src/ifcopenshell-python/ifcopenshell/api/layer/edit_layer.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
#
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
18+
import ifcopenshell
19+
from typing import Any
1820

1921

20-
def edit_layer(file, layer=None, attributes=None) -> None:
22+
def edit_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
2123
"""Edits the attributes of an IfcPresentationLayerAssignment
2224
2325
For more information about the attributes and data types of an
@@ -26,7 +28,7 @@ def edit_layer(file, layer=None, attributes=None) -> None:
2628
:param layer: The IfcPresentationLayerAssignment entity you want to edit
2729
:type layer: ifcopenshell.entity_instance
2830
:param attributes: a dictionary of attribute names and values.
29-
:type attributes: dict, optional
31+
:type attributes: dict
3032
:return: None
3133
:rtype: None
3234
@@ -38,7 +40,7 @@ def edit_layer(file, layer=None, attributes=None) -> None:
3840
ifcopenshell.api.run("layer.edit_layer", model,
3941
layer=layer, attributes={"Description": "All walls, based on the AIA standard."})
4042
"""
41-
settings = {"layer": layer, "attributes": attributes or {}}
43+
settings = {"layer": layer, "attributes": attributes}
4244

4345
for name, value in settings["attributes"].items():
4446
setattr(settings["layer"], name, value)

src/ifcopenshell-python/ifcopenshell/api/layer/remove_layer.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
#
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
18+
import ifcopenshell
1819

1920

20-
def remove_layer(file, layer=None) -> None:
21+
def remove_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance) -> None:
2122
"""Removes a layer
2223
2324
All representation items assigned to the layer will remain, but the
@@ -35,6 +36,4 @@ def remove_layer(file, layer=None) -> None:
3536
layer = ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL")
3637
ifcopenshell.api.run("layer.remove_layer", model, layer=layer)
3738
"""
38-
settings = {"layer": layer}
39-
40-
file.remove(settings["layer"])
39+
file.remove(layer)

src/ifcopenshell-python/ifcopenshell/api/library/add_library.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import ifcopenshell.util.date
2222

2323

24-
def add_library(file, name=None) -> None:
24+
def add_library(file: ifcopenshell.entity_instance, name: str) -> ifcopenshell.entity_instance:
2525
"""Adds a new library to the project
2626
2727
A library is an external data source that is related to the project. It
@@ -60,6 +60,4 @@ def add_library(file, name=None) -> None:
6060
6161
ifcopenshell.api.run("library.add_library", model, name="Brickschema")
6262
"""
63-
settings = {"name": name}
64-
65-
return file.create_entity("IfcLibraryInformation", Name=settings["name"])
63+
return file.create_entity("IfcLibraryInformation", Name=name)

src/ifcopenshell-python/ifcopenshell/api/library/edit_library.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
#
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
18+
import ifcopenshell
19+
from typing import Any
1820

1921

20-
def edit_library(file, library=None, attributes=None) -> None:
22+
def edit_library(file: ifcopenshell.file, library: ifcopenshell.entity_instance, attributes: dict[str, Any]) -> None:
2123
"""Edits the attributes of an IfcLibraryInformation
2224
2325
For more information about the attributes and data types of an
@@ -26,7 +28,7 @@ def edit_library(file, library=None, attributes=None) -> None:
2628
:param library: The IfcLibraryInformation entity you want to edit
2729
:type library: ifcopenshell.entity_instance
2830
:param attributes: a dictionary of attribute names and values.
29-
:type attributes: dict, optional
31+
:type attributes: dict
3032
:return: None
3133
:rtype: None
3234
@@ -39,7 +41,7 @@ def edit_library(file, library=None, attributes=None) -> None:
3941
attributes={"Description": "A Brickschema TTL including only mechanical distribution systems."})
4042
"""
4143

42-
settings = {"library": library, "attributes": attributes or {}}
44+
settings = {"library": library, "attributes": attributes}
4345

4446
for name, value in settings["attributes"].items():
4547
setattr(settings["library"], name, value)

src/ifcopenshell-python/ifcopenshell/api/library/edit_reference.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@
1515
#
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
18+
import ifcopenshell
19+
from typing import Any
1820

1921

20-
def edit_reference(file, reference=None, attributes=None) -> None:
22+
def edit_reference(
23+
file: ifcopenshell.file, reference: ifcopenshell.entity_instance, attributes: dict[str, Any]
24+
) -> None:
2125
"""Edits the attributes of an IfcLibraryReference
2226
2327
For more information about the attributes and data types of an
@@ -26,7 +30,7 @@ def edit_reference(file, reference=None, attributes=None) -> None:
2630
:param reference: The IfcLibraryReference entity you want to edit
2731
:type reference: ifcopenshell.entity_instance
2832
:param attributes: a dictionary of attribute names and values.
29-
:type attributes: dict, optional
33+
:type attributes: dict
3034
:return: None
3135
:rtype: None
3236
@@ -40,7 +44,7 @@ def edit_reference(file, reference=None, attributes=None) -> None:
4044
ifcopenshell.api.run("library.edit_reference", model,
4145
reference=reference, attributes={"Identification": "http://example.org/digitaltwin#AHU01"})
4246
"""
43-
settings = {"reference": reference, "attributes": attributes or {}}
47+
settings = {"reference": reference, "attributes": attributes}
4448

4549
for name, value in settings["attributes"].items():
4650
setattr(settings["reference"], name, value)

src/ifcopenshell-python/ifcopenshell/api/library/remove_library.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import ifcopenshell.util.element
2121

2222

23-
def remove_library(file, library=None) -> None:
23+
def remove_library(file: ifcopenshell.file, library: ifcopenshell.entity_instance) -> None:
2424
"""Removes a library
2525
2626
All references along with their relationships will also be removed. Any

src/ifcopenshell-python/ifcopenshell/api/material/add_constituent.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
#
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
18+
import ifcopenshell
1819

1920

20-
def add_constituent(file, constituent_set=None, material=None) -> None:
21+
def add_constituent(
22+
file: ifcopenshell.file, constituent_set: ifcopenshell.entity_instance, material: ifcopenshell.entity_instance
23+
) -> ifcopenshell.entity_instance:
2124
"""Adds a new constituent to a constituent set
2225
2326
A constituent describes how a portion of an object is made out of a

src/ifcopenshell-python/ifcopenshell/api/material/add_layer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
#
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
18+
import ifcopenshell
1819

1920

20-
def add_layer(file, layer_set=None, material=None) -> None:
21+
def add_layer(
22+
file: ifcopenshell.file, layer_set: ifcopenshell.entity_instance, material: ifcopenshell.entity_instance
23+
) -> ifcopenshell.entity_instance:
2124
"""Adds a new layer to a layer set
2225
2326
A layer represents a portion of material within a layered build up,

src/ifcopenshell-python/ifcopenshell/api/material/add_list_item.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import ifcopenshell
2020

2121

22-
def add_list_item(file, material_list=None, material=None) -> None:
22+
def add_list_item(
23+
file: ifcopenshell.file, material_list: ifcopenshell.entity_instance, material: ifcopenshell.entity_instance
24+
) -> None:
2325
"""Adds a new material in a list of materials
2426
2527
In IFC2X3, if you wanted an object to have multiple materials (i.e. a

0 commit comments

Comments
 (0)