Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions st2client/st2client/commands/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from six.moves import range

from st2client import models
from st2client.models.action import Action, Execution
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought black forces import per line, but maybe that's not the case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For importing packages or modules (import ...), yes it is one import per line as in PEP 8, but not for importing something from a module (from ... import ...).

I find splitting the from ... import ... imports across multiple lines with the same from ... import statement on each line to be overly verbose. If there are too many to fit on one line, then I go for this syntax (assuming it works with the project's code style):

from some.package.module import (
    MY_CONSTANT,
    my_function,
    MyClass,
    something_else,
    another_something_else,
)

I'm not sure if isort or some other tool could enforce that style, but that wouldn't be part of this PR, however we do it.

These answers discuss PEP 8 and import styling:
https://stackoverflow.com/a/15011456
https://stackoverflow.com/a/38427828

from st2client.commands import resource
from st2client.commands.resource import ResourceNotFoundError
from st2client.commands.resource import ResourceViewCommand
Expand Down Expand Up @@ -198,7 +198,7 @@ def format_execution_status(instance):
class ActionBranch(resource.ResourceBranch):
def __init__(self, description, app, subparsers, parent_parser=None):
super(ActionBranch, self).__init__(
models.Action,
Action,
description,
app,
subparsers,
Expand Down Expand Up @@ -1082,7 +1082,7 @@ def _format_for_common_representation(self, task):
task_name_key = "context.orquesta.task_name"
# Use Execution as the object so that the formatter lookup does not change.
# AKA HACK!
return models.action.Execution(
return Execution(
**{
"id": task.id,
"status": task.status,
Expand Down Expand Up @@ -1240,7 +1240,7 @@ def run(self, args, **kwargs):
action=action, runner=runner, args=args
)

execution = models.Execution()
execution = Execution()
execution.action = action_ref
execution.parameters = action_parameters
execution.user = args.user
Expand All @@ -1267,7 +1267,7 @@ def run(self, args, **kwargs):
class ActionExecutionBranch(resource.ResourceBranch):
def __init__(self, description, app, subparsers, parent_parser=None):
super(ActionExecutionBranch, self).__init__(
models.Execution,
Execution,
description,
app,
subparsers,
Expand Down
4 changes: 2 additions & 2 deletions st2client/st2client/commands/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from st2client.base import BaseCLIApp
from st2client import config_parser
from st2client import models
from st2client.models.auth import ApiKey
from st2client.commands import resource
from st2client.commands.noop import NoopCommand
from st2client.exceptions.operations import OperationFailureException
Expand Down Expand Up @@ -278,7 +278,7 @@ def run_and_print(self, args, **kwargs):
class ApiKeyBranch(resource.ResourceBranch):
def __init__(self, description, app, subparsers, parent_parser=None):
super(ApiKeyBranch, self).__init__(
models.ApiKey,
ApiKey,
description,
app,
subparsers,
Expand Down
6 changes: 3 additions & 3 deletions st2client/st2client/commands/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import editor
import yaml

from st2client.models import Config
from st2client.models import Pack
from st2client.models import Execution
from st2client.models.config import Config
from st2client.models.pack import Pack
from st2client.models.action import Execution
from st2client.commands import resource
from st2client.commands.resource import add_auth_token_to_kwargs_from_cli
from st2client.commands.action import ActionRunCommandMixin
Expand Down
6 changes: 3 additions & 3 deletions st2client/st2client/commands/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import logging

from st2client import models
from st2client.models.policy import Policy, PolicyType
from st2client.commands import resource


Expand All @@ -27,7 +27,7 @@
class PolicyTypeBranch(resource.ResourceBranch):
def __init__(self, description, app, subparsers, parent_parser=None):
super(PolicyTypeBranch, self).__init__(
models.PolicyType,
PolicyType,
description,
app,
subparsers,
Expand Down Expand Up @@ -72,7 +72,7 @@ def get_resource(self, ref_or_id, **kwargs):
class PolicyBranch(resource.ResourceBranch):
def __init__(self, description, app, subparsers, parent_parser=None):
super(PolicyBranch, self).__init__(
models.Policy,
Policy,
description,
app,
subparsers,
Expand Down
4 changes: 2 additions & 2 deletions st2client/st2client/commands/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@

from __future__ import absolute_import

from st2client import models
from st2client.models.reactor import Rule
from st2client.commands import resource
from st2client.formatters import table


class RuleBranch(resource.ResourceBranch):
def __init__(self, description, app, subparsers, parent_parser=None):
super(RuleBranch, self).__init__(
models.Rule,
Rule,
description,
app,
subparsers,
Expand Down
4 changes: 2 additions & 2 deletions st2client/st2client/commands/rule_enforcement.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from __future__ import absolute_import

from st2client import models
from st2client.models.reactor import RuleEnforcement
from st2client.commands import resource
from st2client.formatters import table
from st2client.utils.date import format_isodate_for_user_timezone
Expand All @@ -24,7 +24,7 @@
class RuleEnforcementBranch(resource.ResourceBranch):
def __init__(self, description, app, subparsers, parent_parser=None):
super(RuleEnforcementBranch, self).__init__(
models.RuleEnforcement,
RuleEnforcement,
description,
app,
subparsers,
Expand Down
2 changes: 1 addition & 1 deletion st2client/st2client/commands/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from __future__ import absolute_import

from st2client.models import Sensor
from st2client.models.reactor import Sensor
from st2client.commands import resource


Expand Down
2 changes: 1 addition & 1 deletion st2client/st2client/commands/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from __future__ import absolute_import

from st2client.models import Timer
from st2client.models.timer import Timer
from st2client.commands import resource


Expand Down
5 changes: 4 additions & 1 deletion st2client/st2client/commands/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@

from __future__ import absolute_import

from st2client.models import Resource, Trace, TriggerInstance, Rule, Execution
from st2client.models.core import Resource
from st2client.models.trace import Trace
from st2client.models.reactor import TriggerInstance, Rule
from st2client.models.action import Execution
from st2client.formatters import table
from st2client.formatters import execution as execution_formatter
from st2client.commands import resource
Expand Down
2 changes: 1 addition & 1 deletion st2client/st2client/commands/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from __future__ import absolute_import

from st2client.commands import resource
from st2client.models import TriggerType
from st2client.models.reactor import TriggerType
from st2client.formatters import table


Expand Down
2 changes: 1 addition & 1 deletion st2client/st2client/commands/triggerinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from st2client.commands import resource
from st2client.formatters import table
from st2client.models import TriggerInstance
from st2client.models.reactor import TriggerInstance
from st2client.utils.date import format_isodate_for_user_timezone


Expand Down
2 changes: 1 addition & 1 deletion st2client/st2client/commands/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from st2client.commands import resource
from st2client.formatters import table
from st2client.models import Webhook
from st2client.models.webhook import Webhook


class WebhookBranch(resource.ResourceBranch):
Expand Down
2 changes: 1 addition & 1 deletion st2common/st2common/services/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from oslo_config import cfg

from st2client.client import Client
from st2client.models import KeyValuePair
from st2client.models.keyvalue import KeyValuePair
from st2common.util.api import get_full_public_api_url
from st2common.util.date import get_datetime_utc_now
from st2common.constants.keyvalue import DATASTORE_KEY_SEPARATOR, SYSTEM_SCOPE
Expand Down