mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
Add ty to check for missing symbols and other simple errors
This commit is contained in:
@@ -111,8 +111,8 @@ __all__ = [
|
||||
]
|
||||
|
||||
try:
|
||||
from .stream import stream, stream_entity
|
||||
from .stream import stream as _stream
|
||||
from .stream import stream, stream_entity # ty: ignore[possibly-missing-import]
|
||||
from .stream import stream as _stream # ty: ignore[possibly-missing-import]
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@ from __future__ import annotations
|
||||
import math
|
||||
from typing import TYPE_CHECKING, Any, Literal, Optional, Union
|
||||
|
||||
import bmesh # pyright: ignore[reportMissingImports]
|
||||
import bpy # pyright: ignore[reportMissingImports]
|
||||
import bmesh # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
import bpy # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
from mathutils import Matrix, Vector # pyright: ignore[reportMissingImports]
|
||||
from mathutils import Matrix, Vector # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
|
||||
import ifcopenshell.util.shape_builder
|
||||
import ifcopenshell.util.unit
|
||||
|
||||
@@ -431,7 +431,7 @@ class Usecase:
|
||||
)
|
||||
ifcopenshell.api.type.assign_type(
|
||||
self.file,
|
||||
should_run_listeners=False,
|
||||
should_run_listeners=False, # ty:ignore[unknown-argument]
|
||||
related_objects=[element],
|
||||
relating_type=new_type,
|
||||
should_map_representations=False,
|
||||
|
||||
@@ -22,7 +22,7 @@ from typing import TYPE_CHECKING, Any, Optional
|
||||
import ifcopenshell
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import bpy # pyright: ignore[reportMissingImports]
|
||||
import bpy # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
|
||||
|
||||
def add_surface_textures(
|
||||
|
||||
@@ -33,14 +33,14 @@ def _has_occ():
|
||||
# Previous versions (pythonocc<=0.17.3) are using just OCC.
|
||||
|
||||
try:
|
||||
import OCC.Core.BRepTools # pyright: ignore[reportMissingImports]
|
||||
import OCC.Core.BRepTools # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
|
||||
return True
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
try:
|
||||
import OCC.BRepTools # noqa: F401 # pyright: ignore[reportMissingImports]
|
||||
import OCC.BRepTools # noqa: F401 # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
|
||||
return True
|
||||
except ImportError:
|
||||
|
||||
@@ -28,7 +28,7 @@ from ..file import file
|
||||
from . import has_occ
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from OCC.Core import TopoDS # pyright: ignore[reportMissingImports]
|
||||
from OCC.Core import TopoDS # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
|
||||
IteratorOutput = Union["ShapeElementType", "utils.shape_tuple"]
|
||||
|
||||
@@ -47,9 +47,9 @@ if has_occ:
|
||||
from . import occ_utils as utils
|
||||
|
||||
try:
|
||||
from OCC.Core import TopoDS # pyright: ignore[reportMissingImports]
|
||||
from OCC.Core import TopoDS # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
except ImportError:
|
||||
from OCC import TopoDS # pyright: ignore[reportMissingImports]
|
||||
from OCC import TopoDS # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
|
||||
def wrap_shape_creation(settings: settings, shape: ifcopenshell_wrapper.Element):
|
||||
if getattr(settings, "use_python_opencascade", False):
|
||||
|
||||
@@ -26,17 +26,33 @@ import warnings
|
||||
from collections.abc import Iterable
|
||||
from typing import NamedTuple, Union
|
||||
|
||||
import OCC # pyright: ignore[reportMissingImports]
|
||||
import OCC # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
from typing_extensions import assert_never
|
||||
|
||||
import ifcopenshell.ifcopenshell_wrapper as ifcopenshell_wrapper
|
||||
|
||||
try:
|
||||
from OCC.Core import AIS, BRepTools, Graphic3d, Quantity, TopoDS, V3d, gp # pyright: ignore[reportMissingImports]
|
||||
from OCC.Core import ( # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
AIS,
|
||||
BRepTools,
|
||||
Graphic3d,
|
||||
Quantity,
|
||||
TopoDS,
|
||||
V3d,
|
||||
gp,
|
||||
)
|
||||
|
||||
USE_OCCT_HANDLE = False
|
||||
except ImportError:
|
||||
from OCC import AIS, BRepTools, Graphic3d, Quantity, TopoDS, V3d, gp # pyright: ignore[reportMissingImports]
|
||||
from OCC import ( # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
AIS,
|
||||
BRepTools,
|
||||
Graphic3d,
|
||||
Quantity,
|
||||
TopoDS,
|
||||
V3d,
|
||||
gp,
|
||||
)
|
||||
|
||||
USE_OCCT_HANDLE = True
|
||||
|
||||
@@ -68,7 +84,7 @@ DEFAULT_STYLES = {
|
||||
|
||||
|
||||
def initialize_display():
|
||||
import OCC.Display.SimpleGui # pyright: ignore[reportMissingImports]
|
||||
import OCC.Display.SimpleGui # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
|
||||
global handle, main_loop, add_menu, add_function_to_menu
|
||||
handle, main_loop, add_menu, add_function_to_menu = OCC.Display.SimpleGui.init_display()
|
||||
|
||||
@@ -40,7 +40,7 @@ if TYPE_CHECKING:
|
||||
# NOTE: mathutils is never used at runtime in ifcopenshell,
|
||||
# only for type checking to ensure methods are compatible with
|
||||
# Blender vectors.
|
||||
from mathutils import Vector # pyright: ignore[reportMissingImports]
|
||||
from mathutils import Vector # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
|
||||
# Support both numpy arrays and python sequences as inputs.
|
||||
VectorType = Union[Sequence[float], Vector, np.ndarray]
|
||||
|
||||
@@ -47,6 +47,7 @@ from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import functools
|
||||
import itertools
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
@@ -331,7 +332,7 @@ def log_internal_cpp_errors(
|
||||
lines = list(open(filename, "rb"))
|
||||
lengths = list(map(len, lines))
|
||||
cumsum = 0
|
||||
cs = [cumsum := cumsum + x for x in lengths]
|
||||
cs = list(itertools.accumulate(lengths))
|
||||
|
||||
for offsets, msg in zip(chr_offsets, msgs):
|
||||
if offsets:
|
||||
|
||||
@@ -41,7 +41,7 @@ from ifcopenshell.util.shape_builder import (
|
||||
|
||||
class TestMathutilsCompatibleMethods(test.bootstrap.IFC4):
|
||||
def test_np_rotation_matrix(self):
|
||||
from mathutils import Matrix, Vector # pyright: ignore[reportMissingImports]
|
||||
from mathutils import Matrix, Vector # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
|
||||
# 2D.
|
||||
assert np.allclose(Matrix.Rotation(radians(45), 2), np_rotation_matrix(radians(45), 2))
|
||||
@@ -62,7 +62,7 @@ class TestMathutilsCompatibleMethods(test.bootstrap.IFC4):
|
||||
assert np.allclose(Matrix.Rotation(*rotation_vector_args), np_rotation_matrix(*rotation_vector_args))
|
||||
|
||||
def test_np_matrix_to_euler(self):
|
||||
from mathutils import Euler # pyright: ignore[reportMissingImports]
|
||||
from mathutils import Euler # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
|
||||
# Test 3x3.
|
||||
rot = Euler((0.5, 0.5, 0.5)).to_matrix()
|
||||
@@ -77,7 +77,7 @@ class TestMathutilsCompatibleMethods(test.bootstrap.IFC4):
|
||||
assert np.allclose(rot.to_euler(), np_matrix_to_euler(V(rot)))
|
||||
|
||||
def test_np_angle(self):
|
||||
from mathutils import Vector # pyright: ignore[reportMissingImports]
|
||||
from mathutils import Vector # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
|
||||
v1, v2 = (1, 0, 0), (0, 1, 0)
|
||||
angle = np_angle(v1, v2)
|
||||
@@ -100,7 +100,7 @@ class TestMathutilsCompatibleMethods(test.bootstrap.IFC4):
|
||||
assert is_x(angle, radians(90))
|
||||
|
||||
def test_np_normal(self):
|
||||
import mathutils.geometry # pyright: ignore[reportMissingImports]
|
||||
import mathutils.geometry # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
|
||||
vectors = (0, 0, 0), (1, 0, 0), (0, 1, 0)
|
||||
n = mathutils.geometry.normal(vectors)
|
||||
@@ -113,7 +113,7 @@ class TestMathutilsCompatibleMethods(test.bootstrap.IFC4):
|
||||
assert np.allclose(n, (0, 0, -1))
|
||||
|
||||
def test_np_intersect_line_line(self):
|
||||
import mathutils.geometry # pyright: ignore[reportMissingImports]
|
||||
import mathutils.geometry # pyright: ignore[reportMissingImports] # ty:ignore[unresolved-import]
|
||||
|
||||
p1, p2 = [0, 0, 0], [1, 1, 1]
|
||||
q1, q2 = [0, 1, 0], [1, 0, 1]
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
beautifulsoup4
|
||||
cjio >=0.8, <0.10
|
||||
deepdiff
|
||||
docutils
|
||||
flask
|
||||
isodate
|
||||
jinja2
|
||||
lark
|
||||
meshio
|
||||
mysql-connector-python
|
||||
networkx
|
||||
numpy
|
||||
odfpy
|
||||
openpyxl
|
||||
pandas
|
||||
psutil
|
||||
pydantic
|
||||
PyP6Xer
|
||||
pystache
|
||||
pytest
|
||||
python-dateutil
|
||||
requests
|
||||
scikit-learn
|
||||
shapely
|
||||
tabulate
|
||||
toposort
|
||||
typing-extensions
|
||||
typst
|
||||
xlsxwriter
|
||||
xmlschema
|
||||
xsdata
|
||||
Reference in New Issue
Block a user