From fc0069ed600b33a719c95867da6daa8a68718e9c Mon Sep 17 00:00:00 2001 From: Emmanuelle Vargas-Gonzalez Date: Mon, 10 Dec 2018 14:29:31 -0500 Subject: [PATCH] re-order imports, add entry to isort file --- .isort.cfg | 1 + stix2/STIXPatternVisitor.py | 17 +++++++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.isort.cfg b/.isort.cfg index 0780dcd..84bc4c7 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -2,6 +2,7 @@ skip = workbench.py not_skip = __init__.py known_third_party = + antlr4, dateutil, medallion, pytest, diff --git a/stix2/STIXPatternVisitor.py b/stix2/STIXPatternVisitor.py index 6c6690f..0857f02 100644 --- a/stix2/STIXPatternVisitor.py +++ b/stix2/STIXPatternVisitor.py @@ -1,6 +1,7 @@ import importlib import inspect +from antlr4 import CommonTokenStream, InputStream import six from stix2patterns.grammars.STIXPatternLexer import STIXPatternLexer from stix2patterns.grammars.STIXPatternParser import (STIXPatternParser, @@ -8,15 +9,11 @@ from stix2patterns.grammars.STIXPatternParser import (STIXPatternParser, from stix2patterns.grammars.STIXPatternVisitor import STIXPatternVisitor from stix2patterns.validator import STIXPatternErrorListener -from antlr4 import CommonTokenStream, InputStream -from stix2.patterns import (BinaryConstant, BooleanConstant, FloatConstant, - FollowedByObservationExpression, HexConstant, - IntegerConstant, RepeatQualifier, - StartStopQualifier, StringConstant, - TimestampConstant, WithinQualifier) -from stix2.patterns import _BooleanExpression # noqa - -from .patterns import * # noqa: F403, F401 +from .patterns import (BinaryConstant, BooleanConstant, FloatConstant, + FollowedByObservationExpression, HexConstant, + IntegerConstant, RepeatQualifier, StartStopQualifier, + StringConstant, TimestampConstant, WithinQualifier, + _BooleanExpression) def collapse_lists(lists): @@ -46,7 +43,7 @@ class STIXPatternVisitorForSTIX2(STIXPatternVisitor): def __init__(self, module_suffix, module_name): if module_suffix and module_name: self.module_suffix = module_suffix - if STIXPatternVisitorForSTIX2.classes == {}: + if not STIXPatternVisitorForSTIX2.classes: module = importlib.import_module(module_name) for k, c in inspect.getmembers(module, inspect.isclass): STIXPatternVisitorForSTIX2.classes[k] = c