From 68141a465e1b5faaa72714bc7391290fa634164a Mon Sep 17 00:00:00 2001 From: CalCraven Date: Tue, 1 Oct 2024 13:44:51 -0400 Subject: [PATCH] Improve type checking in conversions.py --- gmso/utils/conversions.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gmso/utils/conversions.py b/gmso/utils/conversions.py index 15312cd3..4ffa336d 100644 --- a/gmso/utils/conversions.py +++ b/gmso/utils/conversions.py @@ -1,5 +1,6 @@ """Module for standard conversions needed in molecular simulations.""" - +from __future__ import annotations +from typing import TYPE_CHECKING import re from functools import lru_cache @@ -9,7 +10,9 @@ import unyt as u from unyt.dimensions import length, mass, time -import gmso +if TYPE_CHECKING: + import gmso + from gmso.exceptions import EngineIncompatibilityError, GMSOError from gmso.lib.potential_templates import ( PotentialTemplate, @@ -57,7 +60,7 @@ def _try_sympy_conversions(pot1, pot2): def _conversion_from_template_name( top, connStr: str, conn_typeStr: str, convStr: str -) -> gmso.Topology: +) -> 'gmso.Topology': """Use the name of convStr to identify function to convert sympy expressions.""" conversions_map = { # these are predefined between template types # More functions, and `(to, from)` key pairs added to this dictionary @@ -101,7 +104,7 @@ def _conversion_from_template_name( def _conversion_from_template_obj( - top: gmso.Topology, + top: 'gmso.Topology', connStr: str, conn_typeStr: str, potential_template: gmso.core.ParametricPotential,