mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
typing
This commit is contained in:
@@ -207,6 +207,7 @@ if __name__ == "__main__":
|
||||
print("""
|
||||
# This file is generated by IfcOpenShell ifcexpressparser bootstrap.py
|
||||
|
||||
from __future__ import annotations
|
||||
import os
|
||||
import sys
|
||||
import pickle
|
||||
@@ -217,7 +218,7 @@ import mapping
|
||||
from pyparsing import *
|
||||
from nodes import *
|
||||
|
||||
def parse(fn):
|
||||
def parse(fn: str) -> mapping.Mapping:
|
||||
cache_file = fn + ".cache.dat"
|
||||
if os.path.exists(cache_file) and os.path.getmtime(cache_file) >= os.path.getmtime(fn):
|
||||
with open(cache_file, "rb") as f:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
# This file is generated by IfcOpenShell ifcexpressparser bootstrap.py
|
||||
|
||||
from __future__ import annotations
|
||||
import os
|
||||
import sys
|
||||
import pickle
|
||||
@@ -11,7 +12,7 @@ import mapping
|
||||
from pyparsing import *
|
||||
from nodes import *
|
||||
|
||||
def parse(fn):
|
||||
def parse(fn: str) -> mapping.Mapping:
|
||||
cache_file = fn + ".cache.dat"
|
||||
if os.path.exists(cache_file) and os.path.getmtime(cache_file) >= os.path.getmtime(fn):
|
||||
with open(cache_file, "rb") as f:
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import sys
|
||||
import nodes
|
||||
import templates
|
||||
import schema
|
||||
|
||||
|
||||
class Mapping:
|
||||
@@ -55,7 +57,7 @@ class Mapping:
|
||||
]
|
||||
)
|
||||
|
||||
def __init__(self, schema):
|
||||
def __init__(self, schema: schema.Schema):
|
||||
self.schema = schema
|
||||
|
||||
def flatten_type_string(self, type):
|
||||
|
||||
@@ -3,6 +3,7 @@ import re
|
||||
import ast
|
||||
import collections
|
||||
import ifcopenshell
|
||||
from logging import Logger
|
||||
from dataclasses import dataclass
|
||||
from codegen import indent
|
||||
|
||||
@@ -62,7 +63,7 @@ def fix_type(v):
|
||||
return v
|
||||
|
||||
|
||||
def run(f, logger):
|
||||
def run(f: ifcopenshell.file, logger: Logger) -> None:
|
||||
from _pytest import assertion
|
||||
|
||||
if hasattr(logger, "set_instance"):
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
import nodes
|
||||
import platform
|
||||
import collections
|
||||
import pyparsing
|
||||
|
||||
if tuple(map(int, platform.python_version_tuple())) < (2, 7):
|
||||
import ordereddict
|
||||
@@ -83,7 +84,7 @@ class Schema:
|
||||
def __getitem__(self, key):
|
||||
return self.all_declarations[OrderedCaseInsensitiveDict_KeyObject(key)]
|
||||
|
||||
def __init__(self, parsetree):
|
||||
def __init__(self, parsetree: pyparsing.ParseResults):
|
||||
self.tree = parsetree
|
||||
schema = next(iter(parsetree.syntax[0]))
|
||||
self.name = schema.simple_id
|
||||
|
||||
@@ -17,12 +17,14 @@
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import operator
|
||||
import re
|
||||
|
||||
import nodes
|
||||
import codegen
|
||||
import templates
|
||||
import mapping
|
||||
|
||||
from collections import defaultdict
|
||||
|
||||
@@ -363,7 +365,7 @@ const std::string strings[] = {%s};
|
||||
|
||||
|
||||
class SchemaClass(codegen.Base):
|
||||
def __init__(self, mapping, code=EarlyBoundCodeWriter):
|
||||
def __init__(self, mapping: mapping.Mapping, code=EarlyBoundCodeWriter):
|
||||
class UnmetDependenciesException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user