Skip to content

Commit

Permalink
Merge pull request StackStorm#2250 from StackStorm/lint_improvements
Browse files Browse the repository at this point in the history
Pylint improvements
  • Loading branch information
Kami committed Nov 30, 2015
2 parents 76af332 + 4c1a67e commit 9d799c2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
33 changes: 29 additions & 4 deletions pylint_plugins/api_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
constructor.
"""

import six

from astroid import MANAGER
from astroid import nodes
from astroid import scoped_nodes

# A list of class names for which we want to skip the checks
Expand Down Expand Up @@ -53,11 +56,33 @@ def transform(cls):
# Not a class we are interested in
return

properties = schema.get('properties', {}).keys()

for property_name in properties:
properties = schema.get('properties', {})
for property_name, property_data in six.iteritems(properties):
property_name = property_name.replace('-', '_') # Note: We do the same in Python code
cls.locals[property_name] = [scoped_nodes.Class(property_name, None)]
property_type = property_data.get('type', None)

if isinstance(property_type, (list, tuple)):
# Hack for attributes with multiple types (e.g. string, null)
property_type = property_type[0]

if property_type == 'object':
node = nodes.Dict()
elif property_type == 'array':
node = nodes.List()
elif property_type == 'integer':
node = scoped_nodes.builtin_lookup('int')[1][0]
elif property_type == 'number':
node = scoped_nodes.builtin_lookup('float')[1][0]
elif property_type == 'string':
node = scoped_nodes.builtin_lookup('str')[1][0]
elif property_type == 'boolean':
node = scoped_nodes.builtin_lookup('bool')[1][0]
elif property_type == 'null':
node = scoped_nodes.builtin_lookup('None')[1][0]
else:
node = scoped_nodes.Class(property_name, None)

cls.locals[property_name] = [node]


MANAGER.register_transform(scoped_nodes.Class, transform)
5 changes: 0 additions & 5 deletions st2actions/st2actions/runners/ssh/paramiko_ssh_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# limitations under the License.

import os
import uuid

from oslo_config import cfg
import six
Expand Down Expand Up @@ -189,7 +188,3 @@ def _get_result_status(result, allow_partial_failure):
else:
status = LIVEACTION_STATUS_FAILED
return status


def get_runner():
return BaseParallelSSHRunner(str(uuid.uuid4()))

0 comments on commit 9d799c2

Please sign in to comment.