test suite reviews and discussions
 help / color / mirror / Atom feed
From: ohilyard@iol.unh.edu
To: dts@dpdk.org
Cc: lijuan.tu@intel.com, Owen Hilyard <ohilyard@iol.unh.edu>
Subject: [PATCH] framework/flow: Fix circular import
Date: Mon, 31 Jan 2022 17:09:37 -0500	[thread overview]
Message-ID: <20220131220937.38772-1-ohilyard@iol.unh.edu> (raw)

From: Owen Hilyard <ohilyard@iol.unh.edu>

Some of the re-organization to DTS caused a previously ok circular
import to make the flow generator crash. Moving to local imports has
fixed this.

Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
---
 framework/flow/flow_items.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/framework/flow/flow_items.py b/framework/flow/flow_items.py
index 49684381..cce20b51 100644
--- a/framework/flow/flow_items.py
+++ b/framework/flow/flow_items.py
@@ -37,8 +37,6 @@ import itertools
 from functools import reduce
 from typing import Any, Dict, FrozenSet, Hashable, Iterable, Set, Tuple, Union
 
-import framework.flow.flow_action_items as flow_action_items
-import framework.flow.flow_pattern_items as flow_pattern_items
 
 from .enums import FlowActionType, FlowItemType
 from .exceptions import InvalidFlowItemException
@@ -90,15 +88,17 @@ class FlowItem(object):
         if type(self) != type(other):
             raise InvalidFlowItemException(self, other)
         elif other.type in self.valid_next_items:
-            # This import is in here so there is no circular import
+            # These imports are in here so there is no circular import
             from .flow import Flow
-            if isinstance(self, flow_pattern_items.PatternFlowItem):
+            from framework.flow.flow_pattern_items import PatternFlowItem
+            from framework.flow.flow_action_items import ActionFlowItem
+            if isinstance(self, PatternFlowItem):
                 return Flow(pattern_items=[self, other])
-            elif isinstance(self, flow_action_items.ActionFlowItem):
+            elif isinstance(self, ActionFlowItem):
                 return Flow(action_items=[self, other])
             else:
                 raise TypeError(
-                    f"{type(self):s} is not one of {flow_pattern_items.PatternFlowItem:s}, {flow_action_items.ActionFlowItem:s}.")
+                    f"{type(self):s} is not one of {PatternFlowItem:s}, {ActionFlowItem:s}.")
         else:
             raise InvalidFlowItemException(self, other)
 
-- 
2.30.2


             reply	other threads:[~2022-01-31 22:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-31 22:09 ohilyard [this message]
2022-02-07  8:53 ` Tu, Lijuan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220131220937.38772-1-ohilyard@iol.unh.edu \
    --to=ohilyard@iol.unh.edu \
    --cc=dts@dpdk.org \
    --cc=lijuan.tu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).