Skip to content

Commit

Permalink
Fix pylint issues, replace pylint warning codes by their verbose names
Browse files Browse the repository at this point in the history
  • Loading branch information
tobspr committed Apr 23, 2016
1 parent 8f2631b commit 6b8bc97
Show file tree
Hide file tree
Showing 64 changed files with 197 additions and 275 deletions.
4 changes: 2 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,E0611,W0622,W0201,C0111,R0201
disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,E0611,W0622,W0201,C0111,R0201,R0913,R0902,R0904,R0914


[REPORTS]
Expand Down Expand Up @@ -230,7 +230,7 @@ notes=
[SIMILARITIES]

# Minimum lines number of a similarity.
min-similarity-lines=4
min-similarity-lines=8

# Ignore comments when computing similarities.
ignore-comments=yes
Expand Down
5 changes: 2 additions & 3 deletions rpcore/effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def _parse_shader_template(self, shader_id, data):
shader_path = self._construct_shader_from_data(shader_id, default_template, data)
self._shader_paths[shader_id] = shader_path

def _construct_shader_from_data(self, shader_id, default_template, data):
def _construct_shader_from_data(self, shader_id, default_template, data): # pylint: disable=too-many-branches
""" Constructs a shader from a given dataset """
injects = {}
template_src = default_template
Expand Down Expand Up @@ -227,8 +227,7 @@ def _construct_shader_from_data(self, shader_id, default_template, data):
self.warn("Unrecognized key:", key)

shader = ShaderTemplate(
template_src,
self._effect_name + "@" + shader_id + "@" + self._effect_hash)
template_src, self._effect_name + "@" + shader_id + "@" + self._effect_hash)

for key, val in iteritems(injects):
shader.register_template_value(key, val)
Expand Down
2 changes: 1 addition & 1 deletion rpcore/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

__all__ = ("Globals",)

class Globals(object):
class Globals(object): # pylint: disable=too-few-public-methods

""" This class is a singleton to store globals widely used by the application.
This is a wrapper around Panda3D's globals since ShowBase writes to __builtins__
Expand Down
6 changes: 3 additions & 3 deletions rpcore/gui/buffer_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ def _perform_update(self):

self._render_stages()

def _on_texture_hovered(self, hover_frame, evt=None): # pylint: disable=W0613
def _on_texture_hovered(self, hover_frame, evt=None): # pylint: disable=unused-argument
""" Internal method when a texture is hovered """
hover_frame["frameColor"] = (0, 0, 0, 0.1)

def _on_texture_blurred(self, hover_frame, evt=None): # pylint: disable=W0613
def _on_texture_blurred(self, hover_frame, evt=None): # pylint: disable=unused-argument
""" Internal method when a texture is blurred """
hover_frame["frameColor"] = (0, 0, 0, 0)

def _on_texture_clicked(self, tex_handle, evt=None): # pylint: disable=W0613
def _on_texture_clicked(self, tex_handle, evt=None): # pylint: disable=unused-argument
""" Internal method when a texture is blurred """
self._tex_preview.present(tex_handle)

Expand Down
17 changes: 11 additions & 6 deletions rpcore/gui/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from __future__ import division

from rplibs.six.moves import range
from rplibs.six.moves import range # pylint: disable=import-error

from panda3d.core import Vec4, Vec3, Vec2, RenderState, TransformState
from panda3d.core import TexturePool, SceneGraphAnalyzer
Expand Down Expand Up @@ -132,8 +132,10 @@ def create_hints(self):
image="/$$rp/data/gui/python_warning.png",
parent=self.fullscreen_node)
Sequence(
self.python_warning.color_scale_interval(0.7, Vec4(0.3, 1, 1, 0.7), blendType="easeOut"),
self.python_warning.color_scale_interval(0.7, Vec4(1, 1, 1, 1.0), blendType="easeOut"),
self.python_warning.color_scale_interval(
0.7, Vec4(0.3, 1, 1, 0.7), blendType="easeOut"),
self.python_warning.color_scale_interval(
0.7, Vec4(1, 1, 1, 1.0), blendType="easeOut"),
).loop()

# Keybinding hints
Expand Down Expand Up @@ -255,7 +257,8 @@ def update_stats(self, task=None):
if self.pipeline.plugin_mgr.is_plugin_enabled("scattering"):
sun_vector = self.pipeline.plugin_mgr.instances["scattering"].sun_vector

text = "{} ({:1.3f}) | {:0.2f} {:0.2f} {:0.2f} | {:3d} daytime settings | X {:3.1f} Y {:3.1f} Z {:3.1f}"
text = "{} ({:1.3f}) | {:0.2f} {:0.2f} {:0.2f} | {:3d} daytime settings"
text += " | X {:3.1f} Y {:3.1f} Z {:3.1f}"
text += " | Total tasks: {:2d} | scheduled: {:2d}"
self.debug_lines[4].text = text.format(
self.pipeline.daytime_mgr.formatted_time,
Expand All @@ -272,13 +275,15 @@ def update_stats(self, task=None):
if "pssm" in self.pipeline.plugin_mgr.enabled_plugins:
focus = self.pipeline.plugin_mgr.instances["pssm"].scene_shadow_stage.last_focus
if focus is not None:
text += "{:3.1f} {:3.1f} {:3.1f} r {:3.1f}".format(focus[0].x, focus[0].y, focus[0].z, focus[1])
text += "{:3.1f} {:3.1f} {:3.1f} r {:3.1f}".format(
focus[0].x, focus[0].y, focus[0].z, focus[1])
else:
text += "none"
else:
text += "inactive"

text += " | H {:3.1f} P {:3.1f} R {:3.1f} | {:4d} x {:4d} pixels @ {:3.1f} % | {:3d} x {:3d} tiles"
text += " | H {:3.1f} P {:3.1f} R {:3.1f} | {:4d} x {:4d} pixels @ {:3.1f} %"
text += " | {:3d} x {:3d} tiles"
self.debug_lines[5].text = text.format(
Globals.base.camera.get_h(Globals.base.render),
Globals.base.camera.get_p(Globals.base.render),
Expand Down
15 changes: 8 additions & 7 deletions rpcore/gui/draggable_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ def _create_components(self):
self._node = self._parent.attach_new_node("Window")
self._node.set_pos(self._pos.x, 1, -self._pos.y)
border_px = 1
border_frame_size = (-border_px, self._width + border_px,
border_px, -self._height - border_px)
self._border_frame = DirectFrame(
pos=(0, 1, 0), frameSize=(-border_px, self._width + border_px,
border_px, -self._height - border_px),
pos=(0, 1, 0), frameSize=border_frame_size,
frameColor=(24 / 255.0, 131 / 255.0, 215 / 255.0, 1),
parent=self._node, state=DGG.NORMAL)
self._background = DirectFrame(
Expand Down Expand Up @@ -111,7 +112,7 @@ def _create_components(self):
self._title_bar.bind(DGG.B1PRESS, self._start_drag)
self._title_bar.bind(DGG.B1RELEASE, self._stop_drag)

def _start_drag(self, evt=None): # pylint: disable=W0613
def _start_drag(self, evt=None): # pylint: disable=unused-argument
""" Gets called when the user starts dragging the window """
self._dragging = True
self._node.detach_node()
Expand All @@ -120,19 +121,19 @@ def _start_drag(self, evt=None): # pylint: disable=W0613
uponDeath=self._stop_drag)
self._drag_offset = self._pos - self._get_mouse_pos()

def _on_close_btn_hover(self, evt=None): # pylint: disable=W0613
def _on_close_btn_hover(self, evt=None): # pylint: disable=unused-argument
""" Internal method when the close button got hovered """
self._btn_close["image"] = "/$$rp/data/gui/close_window_hover.png"

def _on_close_btn_out(self, evt=None): # pylint: disable=W0613
def _on_close_btn_out(self, evt=None): # pylint: disable=unused-argument
""" Internal method when the close button is no longer hovered """
self._btn_close["image"] = "/$$rp/data/gui/close_window.png"

def _request_close(self, evt=None): # pylint: disable=W0613
def _request_close(self, evt=None): # pylint: disable=unused-argument
""" This method gets called when the close button gets clicked """
self.hide()

def _stop_drag(self, evt=None): # pylint: disable=W0613
def _stop_drag(self, evt=None): # pylint: disable=unused-argument
""" Gets called when the user stops dragging the window """
Globals.base.taskMgr.remove("UIWindowDrag")
self._dragging = False
Expand Down
4 changes: 2 additions & 2 deletions rpcore/gui/labeled_checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ def __init__(self, parent=None, x=0, y=0, chb_callback=None,
self._checkbox.node.bind(DGG.WITHIN, self._on_node_enter)
self._checkbox.node.bind(DGG.WITHOUT, self._on_node_leave)

def _on_node_enter(self, *args): # pylint: disable=W0613
def _on_node_enter(self, *args): # pylint: disable=unused-argument
""" Internal callback when the node gets hovered """
self._text.node["fg"] = (self.text_color.x + 0.1, self.text_color.y + 0.1,
self.text_color.z + 0.1, 1.0)

def _on_node_leave(self, *args): # pylint: disable=W0613
def _on_node_leave(self, *args): # pylint: disable=unused-argument
""" Internal callback when the node gets no longer hovered """
self._text.node["fg"] = (self.text_color.x, self.text_color.y, self.text_color.z, 1.0)

Expand Down
2 changes: 1 addition & 1 deletion rpcore/gui/loading_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"""
from __future__ import division

from rplibs.six.moves import range
from rplibs.six.moves import range # pylint: disable=import-error

from rpcore.gui.sprite import Sprite
from rpcore.rpobject import RPObject
Expand Down
2 changes: 1 addition & 1 deletion rpcore/gui/pipe_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _update_task(self, task=None):
self._pipe_descriptions.set_x(scroll_value * 2759.0)
return task.cont

def _populate_content(self):
def _populate_content(self): # pylint: disable=too-many-branches,too-many-statements
""" Reads the pipes and stages from the stage manager and renders those
into the window """
self._created = True
Expand Down
2 changes: 1 addition & 1 deletion rpcore/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from rpcore.globals import Globals
from rpcore.render_target import RenderTarget

class StuffToMakePylintHappyAgain(object):
class StuffToMakePylintHappyAgain(object): # pylint: disable=too-few-public-methods

""" This is a small helper class to prevent pylint errors about the Image
class not defining the enums """
Expand Down
2 changes: 1 addition & 1 deletion rpcore/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

__all__ = ("RPLoader",)

class timed_loading_operation(object): # pylint: disable=C0103
class timed_loading_operation(object): # pylint: disable=invalid-name,too-few-public-methods

""" Context manager for a synchronous loading operation, keeping track
on how much time elapsed during the loading process, and warning about
Expand Down
7 changes: 3 additions & 4 deletions rpcore/native/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"""

# Disable the invalid constant name warning
# pylint: disable=C0103
# pylint: disable=invalid-name

# This file includes all modules from the native module.

Expand Down Expand Up @@ -76,9 +75,9 @@
# If the module was built, use it, otherwise use the python wrappers
if NATIVE_CXX_LOADED:
RPObject.global_debug("CORE", "Using native core module")
from rpcore.native import native_ as _native_module
from rpcore.native import native_ as _native_module # pylint: disable=wrong-import-position
else:
from rpcore import pynative as _native_module
from rpcore import pynative as _native_module # pylint: disable=wrong-import-position
RPObject.global_debug("CORE", "Using simulated python-wrapper module")

# Import all classes
Expand Down
15 changes: 2 additions & 13 deletions rpcore/pluginbase/day_setting_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

from rpcore.rpobject import RPObject
from rpcore.util.smooth_connected_curve import SmoothConnectedCurve
from rpcore.pluginbase.setting_types import make_setting_from_factory

__all__ = ["make_daysetting_from_data"]

Expand All @@ -42,19 +43,7 @@ def make_daysetting_from_data(data):
"color": ColorType,
"scalar": ScalarType
}
if data["type"] not in factory:
raise Exception("Unkown setting type: {}".format(data["type"]))

try:
instance = factory[data["type"]](data)
except Exception:
print("Exception occured while parsing", data)
raise

if data:
raise Exception("Unparsed data left in plugin setting: {}".format(data))
return instance

return make_setting_from_factory(data, factory)

class BaseType(RPObject):
""" Base setting type for all setting types """
Expand Down
5 changes: 0 additions & 5 deletions rpcore/pluginbase/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,6 @@ def load_plugin_settings(self, plugin_id, plugin_pth):
config["settings"] = config["settings"] or []
config["daytime_settings"] = config["daytime_settings"] or []

if isinstance(config["settings"], dict) or isinstance(config["daytime_settings"], dict) or \
(config["settings"] and len(config["settings"][0]) != 2) or \
(config["daytime_settings"] and len(config["daytime_settings"][0]) != 2):
self.error("Malformed config for plugin", plugin_id, "- did you miss '!!omap' ?")

settings = collections.OrderedDict(
[(k, make_setting_from_data(v)) for k, v in config["settings"]])
self.settings[plugin_id] = settings
Expand Down
27 changes: 15 additions & 12 deletions rpcore/pluginbase/setting_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@

__all__ = ["make_setting_from_data"]

def make_setting_from_factory(data, factory):
""" Constructs a new setting from a given dataset, alongst with a factory
to resolve the setting type to """
if data["type"] not in factory:
raise Exception("Unkown setting type: {}".format(data["type"]))
try:
instance = factory[data["type"]](data)
except Exception:
print("Exception occured while parsing", data)
raise
if data:
raise Exception("Unparsed data left in plugin setting: {}".format(data))
return instance

def make_setting_from_data(data):
""" Constructs a new setting from a given dataset. This method will automatically
instantiate a new class matching the type of the given dataset. It will fill
Expand All @@ -42,18 +56,7 @@ def make_setting_from_data(data):
"enum": EnumType,
"path": PathType
}
if data["type"] not in factory:
raise Exception("Unkown setting type: {}".format(data["type"]))

try:
instance = factory[data["type"]](data)
except Exception:
print("Exception occured while parsing", data)
raise

if data:
raise Exception("Unparsed data left in plugin setting: {}".format(data))
return instance
return make_setting_from_factory(data, factory)

class BaseType(RPObject):

Expand Down
4 changes: 2 additions & 2 deletions rpcore/pynative/gpu_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"""

from __future__ import print_function
from rplibs.six.moves import range
from rplibs.six.moves import range # pylint: disable=import-error

import struct

Expand Down Expand Up @@ -79,6 +79,6 @@ def write_to(self, dest, command_index):
offset = command_index * 32 * 4
dest.set_subdata(offset, 32 * 4, data)

def write(self, out=None): # pylint: disable=W0613
def write(self, out=None): # pylint: disable=unused-argument
print("GPUCommand(type=", self._command_type, "size=", self._current_index, ")")
print("Data:", ', '.join([str(i) for i in self._data]))
4 changes: 2 additions & 2 deletions rpcore/pynative/ies_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"""

from rplibs.six.moves import range
from rplibs.six.moves import range # pylint: disable=import-error

import math
from panda3d.core import PNMImage
Expand Down Expand Up @@ -64,7 +64,7 @@ def generate_dataset_texture_into(self, dest_tex, layer_index):

dest_tex.load(dest, layer_index, 0)

def get_candela_value(self, vertical_angle, horizontal_angle): # pylint: disable=W0613
def get_candela_value(self, vertical_angle, horizontal_angle): # pylint: disable=unused-argument
# NOTICE: Since python is slower, we always only assume a dataset without
# horizontal angles. This still produces convincing results, but does
# generate much faster.
Expand Down
2 changes: 1 addition & 1 deletion rpcore/pynative/internal_light_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"""
from __future__ import print_function
from rplibs.six.moves import range
from rplibs.six.moves import range # pylint: disable=import-error

from panda3d.core import Vec3

Expand Down
2 changes: 1 addition & 1 deletion rpcore/pynative/pointer_slot_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"""

from rplibs.six.moves import range
from rplibs.six.moves import range # pylint: disable=import-error

class PointerSlotStorage(object):

Expand Down
4 changes: 2 additions & 2 deletions rpcore/pynative/pssm_camera_rig.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def compute_mvp(self):
transform = self._parent.get_transform(self._cam_node).get_mat()
return transform * self._lens.get_projection_mat()

def get_camera(self, index): # pylint: disable=W0613
def get_camera(self, index): # pylint: disable=unused-argument
return self._cam_node

def set_sun_distance(self, dist):
Expand All @@ -90,7 +90,7 @@ def get_nearfar_array(self):
def set_use_stable_csm(self, use_stable):
self._snap_grid = use_stable

def _stub(self, *args, **kwargs): # pylint: disable=W0613
def _stub(self, *args, **kwargs): # pylint: disable=unused-argument
return None

set_pssm_distance = _stub
Expand Down
Loading

0 comments on commit 6b8bc97

Please sign in to comment.