Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.

Commit

Permalink
Update warnings to match existing conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed May 31, 2017
1 parent e0ab729 commit b35ce59
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .pylint.ini
Expand Up @@ -65,7 +65,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=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,import-star-module-level,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,long-suffix,old-ne-operator,old-octal-literal,suppressed-message,useless-suppression,locally-disabled,fixme,too-few-public-methods,too-many-public-methods,invalid-name,global-statement,too-many-ancestors,missing-docstring
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,import-star-module-level,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,long-suffix,old-ne-operator,old-octal-literal,suppressed-message,useless-suppression,locally-disabled,fixme,too-few-public-methods,too-many-public-methods,invalid-name,global-statement,too-many-ancestors,missing-docstring,no-else-return,too-many-instance-attributes,too-many-branches,arguments-differ


[REPORTS]
Expand Down
3 changes: 3 additions & 0 deletions tests/test_files.py
Expand Up @@ -33,14 +33,17 @@ class SampleStandardDecorated:
"""Sample class using standard attribute types."""

def __init__(self, name, category='default'):
# pylint: disable=duplicate-code
self.name = name
self.category = category
# https://docs.python.org/3.4/library/json.html#json.JSONDecoder
self.object = {}
self.array = []
# pylint: disable=duplicate-code
self.string = ""
self.number_int = 0
self.number_real = 0.0
# pylint: disable=duplicate-code
self.true = True
self.false = False
self.null = None
Expand Down
1 change: 1 addition & 0 deletions tests/test_ordering.py
Expand Up @@ -30,6 +30,7 @@ def test_attribute_order_is_maintained(tmpdir):
sample.string = "Hello, world!"
sample.number_int = 42
sample.number_real = 4.2
# pylint: disable=duplicate-code
sample.truthy = False
sample.falsey = True
sample.dictionary['status'] = 1
Expand Down
6 changes: 2 additions & 4 deletions yorm/bases/mappable.py
Expand Up @@ -10,14 +10,13 @@


def load_before(method):
"""Decorator for methods that should load before call."""
"""Decorate methods that should load before call."""

if getattr(method, '_load_before', False):
return method

@functools.wraps(method)
def wrapped(self, *args, **kwargs):
"""Decorated method."""
__tracebackhide__ = True # pylint: disable=unused-variable

if not _private_call(method, args):
Expand All @@ -37,14 +36,13 @@ def wrapped(self, *args, **kwargs):


def save_after(method):
"""Decorator for methods that should save after call."""
"""Decorate methods that should save after call."""

if getattr(method, '_save_after', False):
return method

@functools.wraps(method)
def wrapped(self, *args, **kwargs):
"""Decorated method."""
__tracebackhide__ = True # pylint: disable=unused-variable

result = method(self, *args, **kwargs)
Expand Down
10 changes: 6 additions & 4 deletions yorm/common.py
Expand Up @@ -28,13 +28,15 @@
# LOGGING ######################################################################


def _trace(self, message, *args, **kwargs): # pragma: no cover (manual test)
"""Handler for a new TRACE logging level."""
logging.addLevelName(logging.DEBUG - 1, 'TRACE')


def _trace(self, message, *args, **kwargs):
if self.isEnabledFor(logging.DEBUG - 1):
self._log(logging.DEBUG - 1, message, args, **kwargs) # pylint: disable=protected-access
# pylint: disable=protected-access
self._log(logging.DEBUG - 1, message, args, **kwargs)


logging.addLevelName(logging.DEBUG - 1, "TRACE")
logging.Logger.trace = _trace


Expand Down
5 changes: 2 additions & 3 deletions yorm/decorators.py
Expand Up @@ -12,7 +12,7 @@


def sync(*args, **kwargs):
"""Convenience function to forward calls based on arguments.
"""Decorate class or map object based on arguments.
This function will call either:
Expand Down Expand Up @@ -64,7 +64,7 @@ def sync_object(instance, path, attrs=None, **kwargs):


def sync_instances(path_format, format_spec=None, attrs=None, **kwargs):
"""Class decorator to enable YAML mapping after instantiation.
"""Decorate class to enable YAML mapping after instantiation.
:param path_format: formatting string to create file paths for dump/parse
:param format_spec: dictionary to use for string formatting
Expand All @@ -83,7 +83,6 @@ def decorator(cls):
init = cls.__init__

def modified_init(self, *_args, **_kwargs):
"""Modified class __init__ that maps the resulting instance."""
init(self, *_args, **_kwargs)

log.info("Mapping instance of %r to '%s'...", cls, path_format)
Expand Down
4 changes: 2 additions & 2 deletions yorm/mapper.py
Expand Up @@ -11,7 +11,7 @@


def file_required(method):
"""Decorator for methods that require the file to exist."""
"""Decorate methods that require the file to exist."""

@functools.wraps(method)
def wrapped(self, *args, **kwargs):
Expand All @@ -28,7 +28,7 @@ def wrapped(self, *args, **kwargs):


def prevent_recursion(method):
"""Decorator to prevent indirect recursive calls."""
"""Decorate methods to prevent indirect recursive calls."""

@functools.wraps(method)
def wrapped(self, *args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion yorm/tests/test_bases_container.py
Expand Up @@ -23,7 +23,7 @@ def create_default(cls):
def to_data(cls, value):
return str(value.value)

def update_value(self, data, *, auto_track=None): # pylint: disable=unused-variable
def update_value(self, data, *, auto_track=None): # pylint: disable=unused-argument
self.value += int(data)

def test_container_class_cannot_be_instantiated(self):
Expand Down
6 changes: 3 additions & 3 deletions yorm/tests/test_decorators.py
@@ -1,4 +1,4 @@
# pylint: disable=unused-variable,expression-not-assigned
# pylint: disable=unused-variable,unused-argument,expression-not-assigned
# pylint: disable=missing-docstring,no-self-use,no-member,misplaced-comparison-constant

import logging
Expand All @@ -21,11 +21,11 @@ def create_default(cls):
return None

@classmethod
def to_value(cls, *_):
def to_value(cls, data):
return None

@classmethod
def to_data(cls, _):
def to_data(cls, value):
return None


Expand Down

0 comments on commit b35ce59

Please sign in to comment.