Skip to content

Commit

Permalink
pylint & pep257: Resolve issues in python coding style.
Browse files Browse the repository at this point in the history
This resolves most pylint and pep8 and pep257 issues pointed out via
prospector pylint and should be formatted according to black.

prospector --profile .prospector.yml ./bindings/python/examples/iio_info.py
pylint --rcfile=.pylintrc ./bindings/python/examples/iio_info.py
black ./bindings/python/examples/iio_info.py

There are still some issues with the way that globals are handled, but I
think it is OK for now, and makes the generated doc look better as
well.

Signed-off-by: Robin Getz <[email protected]>
  • Loading branch information
rgetz committed May 19, 2020
1 parent 8606010 commit e306929
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 157 deletions.
16 changes: 16 additions & 0 deletions .prospector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,22 @@ pyroma:
mypy:
run: false

mccabe:
run: false

pylint:
run: false

pydocroma:
run: true

pyflakes:
run: true

pep8:
run: true
disable: [
N811, # false negatives from from ctypes import
E501, # Line-length, already controlled by pylint
E302, # expected 2 blank lines, found 1, controlled by black
]
Expand All @@ -33,8 +40,17 @@ pep257:
run: true
# see http://pep257.readthedocs.io/en/latest/error_codes.html
disable: [
# numpy convention
D107, # Missing docstring in __init__
D203, # 1 blank line required before class docstring
# conflicts with D0211, No blank lines allowed before class docstring
D205, # 1 blank line required between summary line and description
D212, # Multi-line docstring summary should start at the first line
# Conflictes with D213 / Multi-line docstring summary should start at the second line
D213, # Multi-line docstring summary should start at the second line
D402, # First line should not be the function's "signature"
# conflicts with D213, Multi-line docstring summary should start at the second line
D406, # Section name should end with a newline
D407, # Missing dashed underline after section
D413, # Missing blank line after last section
]
4 changes: 1 addition & 3 deletions bindings/python/examples/iio_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@


def main():
"""
Dump iio devices, list all iio attributes.
"""
"""Dump iio devices, list all iio attributes."""
print("Library version: %u.%u (git tag: %s)" % iio.version)

if len(argv) == 3 and argv[1] == "--uri":
Expand Down
9 changes: 6 additions & 3 deletions bindings/python/examples/iio_readdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ class ContextBuilder:

def __init__(self, arguments):
"""
ContextBuilder class constructor.
Class constructor.
Args:
arguments: type=Arguments
Contains the input arguments.
Expand Down Expand Up @@ -156,7 +157,8 @@ class BufferBuilder:

def __init__(self, ctx, arguments):
"""
BufferBuilder class constructor.
Class constructor.
Args:
ctx: type=iio.Context
This buffer's context.
Expand Down Expand Up @@ -202,7 +204,8 @@ class DataReader:

def __init__(self, ctx, arguments):
"""
DataWriter class constructor.
Class constructor.
Args:
ctx: type=iio.Context
Current context.
Expand Down
9 changes: 6 additions & 3 deletions bindings/python/examples/iio_writedev.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class ContextBuilder:

def __init__(self, arguments):
"""
ContextBuilder class constructor.
Class constructor.
Args:
arguments: type=Arguments
Contains the input arguments.
Expand Down Expand Up @@ -161,7 +162,8 @@ class BufferBuilder:

def __init__(self, ctx, arguments):
"""
BufferBuilder class constructor.
Class constructor.
Args:
ctx: type=iio.Context
This buffer's context.
Expand Down Expand Up @@ -207,7 +209,8 @@ class DataWriter:

def __init__(self, ctx, arguments):
"""
DataWriter class constructor.
Class constructor.
Args:
ctx: type=iio.Context
Current context.
Expand Down
Loading

0 comments on commit e306929

Please sign in to comment.