type hints and lint

This commit is contained in:
Forgejo Actions 2026-04-21 21:13:34 -07:00
commit c6c9159b13
30 changed files with 198 additions and 136 deletions

View file

@ -14,6 +14,7 @@ simple straight interface:
from __future__ import annotations
import importlib
from typing import TYPE_CHECKING
import numpy
from numpy import pi
@ -24,6 +25,9 @@ from gridlock import Extent
from meanas.fdfd import eme, waveguide_2d
from meanas.fdmath import unvec
if TYPE_CHECKING:
from types import ModuleType
WL = 1310.0
DX = 40.0
@ -35,7 +39,7 @@ EPS_OX = 1.453 ** 2
MODE_NUMBERS = numpy.array([0])
def require_optional(name: str, package_name: str | None = None):
def require_optional(name: str, package_name: str | None = None) -> ModuleType:
package_name = package_name or name
try:
return importlib.import_module(name)
@ -159,7 +163,7 @@ def print_summary(ss: numpy.ndarray, wavenumbers_left: numpy.ndarray, wavenumber
def plot_results(
*,
pyplot,
pyplot: ModuleType,
ss: numpy.ndarray,
left_mode: tuple[numpy.ndarray, numpy.ndarray],
right_mode: tuple[numpy.ndarray, numpy.ndarray],