mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 13:46:54 +00:00
typing
This commit is contained in:
@@ -19,9 +19,14 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import sys
|
import sys
|
||||||
import nodes
|
from typing import TYPE_CHECKING
|
||||||
import templates
|
|
||||||
import schema
|
if TYPE_CHECKING:
|
||||||
|
from . import nodes, schema, templates
|
||||||
|
else:
|
||||||
|
import nodes
|
||||||
|
import schema
|
||||||
|
import templates
|
||||||
|
|
||||||
|
|
||||||
class Mapping:
|
class Mapping:
|
||||||
@@ -117,8 +122,8 @@ class Mapping:
|
|||||||
else:
|
else:
|
||||||
return "Type::%s" % type
|
return "Type::%s" % type
|
||||||
|
|
||||||
def make_argument_type(self, attr):
|
def make_argument_type(self, attr: nodes.Node | str) -> str:
|
||||||
def _make_argument_type(type):
|
def _make_argument_type(type: nodes.Node | str) -> str:
|
||||||
if isinstance(type, nodes.SimpleType):
|
if isinstance(type, nodes.SimpleType):
|
||||||
type = type.type
|
type = type.type
|
||||||
if self.schema.is_entity(type) or isinstance(type, nodes.SelectType):
|
if self.schema.is_entity(type) or isinstance(type, nodes.SelectType):
|
||||||
@@ -253,10 +258,10 @@ class Mapping:
|
|||||||
derived = set(self.derived_in_supertype(t))
|
derived = set(self.derived_in_supertype(t))
|
||||||
attrs = enumerate(self.arguments(t))
|
attrs = enumerate(self.arguments(t))
|
||||||
|
|
||||||
def include(attr):
|
def include(attr: nodes.Node) -> bool:
|
||||||
not_derived = include_derived or (attr.name not in derived)
|
not_derived = include_derived or (attr.name not in derived)
|
||||||
supported = self.make_argument_type(attr) != "ifcopenshell::Argument_UNKNOWN"
|
supported = self.make_argument_type(attr) != "ifcopenshell::Argument_UNKNOWN"
|
||||||
return not_derived and supported
|
return bool(not_derived and supported)
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user