Skip to content

Commit

Permalink
pylint: fix code or suppress false positives for pylint 1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJJ committed Dec 9, 2015
1 parent b1fdd74 commit 84a61f9
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 29 deletions.
14 changes: 0 additions & 14 deletions etc/pylintrc
Expand Up @@ -7,9 +7,6 @@
# pygtk.require().
#init-hook=

# Profiled execution.
profile=no

# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS
Expand Down Expand Up @@ -56,10 +53,6 @@ reports=yes
# (RP0004).
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)

# Add a comment according to your evaluation note. This is used by the global
# evaluation report (RP0004).
comment=no

# Template used to display messages. This is a python new-style format string
# used to format the message information. See doc for all details
#msg-template=
Expand Down Expand Up @@ -100,9 +93,6 @@ notes=FIXME,XXX,ASDF

[BASIC]

# Required attributes for module, separated by a comma
required-attributes=

# List of builtins function names that should not be used, separated by a comma
bad-functions=map,filter

Expand Down Expand Up @@ -203,10 +193,6 @@ ignored-modules=
# (useful for classes with attributes dynamically set).
ignored-classes=SQLObject

# When zope mode is activated, add a predefined set of Zope acquired attributes
# to generated-members.
zope=no

# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E0201 when accessed. Python regular
# expressions are accepted.
Expand Down
1 change: 1 addition & 0 deletions openage/__init__.py
Expand Up @@ -17,6 +17,7 @@


try:
# TODO pylint: disable=wrong-import-position
import openage.config as config

except ImportError:
Expand Down
4 changes: 2 additions & 2 deletions openage/__main__.py
Expand Up @@ -8,6 +8,8 @@
"""

import argparse
# TODO remove this once all multiprocessing has been eliminated:
import multiprocessing
import os

from .log.logging import set_loglevel, verbosity_to_level, ENV_VERBOSITY
Expand Down Expand Up @@ -88,8 +90,6 @@ def main(argv=None):


if __name__ == '__main__':
# TODO remove this once all multiprocessing has been eliminated.
import multiprocessing
# openage is complicated and multithreaded; better not use fork.
# TODO fix pending pylint 1.5: pylint: disable=no-member
multiprocessing.set_start_method('spawn')
Expand Down
9 changes: 5 additions & 4 deletions openage/cabextract/cab.py
Expand Up @@ -206,7 +206,7 @@ def verify_checksum(self):
# the final part is from the actual data
checksum ^= mscab_csum(self.payload)

if not checksum == self.csum:
if checksum != self.csum:
raise ValueError("checksum error in MSCAB data block")


Expand Down Expand Up @@ -336,6 +336,7 @@ def read_folder_headers(self, cab):
window_bits=window_bits,
reset_interval=0)

# pylint: disable=redefined-variable-type
folder.plain_stream = StreamSeekBuffer(unseekable_plain_stream)

else:
Expand All @@ -361,13 +362,13 @@ def read_file_headers(self, cab):
fileobj = CFFile.read(cab)

# read filename
path = read_nullterminated_string(cab)
rpath = read_nullterminated_string(cab)

# decode filename according to flags
if fileobj.attribs.name_is_utf:
path = path.decode('utf-8')
path = rpath.decode('utf-8')
else:
path = path.decode('iso-8859-1')
path = rpath.decode('iso-8859-1')

fileobj.path = path.replace('\\', '/').lower().encode().split(b'/')

Expand Down
4 changes: 2 additions & 2 deletions openage/codegen/codegen.py
Expand Up @@ -240,8 +240,8 @@ def postprocess_write(parts, data):
"""
Post-processes a single write operation, as intercepted during codegen.
"""
# test whether filename starts with 'cpp/'
if not parts[0] == b"libopenage":
# test whether filename starts with 'libopenage/'
if parts[0] != b"libopenage":
raise ValueError("Not in libopenage source directory")

# test whether filename matches the pattern *.gen.*
Expand Down
3 changes: 2 additions & 1 deletion openage/config.py.in
Expand Up @@ -9,6 +9,8 @@
Project configuration, writen by the build system.
"""

import importlib

GLOBAL_ASSET_DIR = "${INSTALLED_GLOBAL_ASSET_DIR}"
BUILD_SRC_DIR = "${CMAKE_SOURCE_DIR}"
BUILD_BIN_DIR = "${CMAKE_BINARY_DIR}"
Expand All @@ -23,7 +25,6 @@ COMPILERFLAGS = "${CMAKE_CXX_FLAGS}"
CYTHONVERSION = "${CYTHON_VERSION}"

try:
import importlib
importlib.import_module("openage.devmode")
DEVMODE = True
except ImportError:
Expand Down
2 changes: 1 addition & 1 deletion openage/convert/changelog.py
Expand Up @@ -61,6 +61,6 @@ def test():
"""

for entry in CHANGES:
if not entry <= COMPONENTS:
if entry > COMPONENTS:
invalid = entry - COMPONENTS
raise TestError("'{}': invalid changelog entry".format(invalid))
4 changes: 2 additions & 2 deletions openage/testing/main.py
Expand Up @@ -57,11 +57,11 @@ def process_args(args, error):
args.test = [name for name, type_ in test_list if type_ == 'test']

for test in args.test:
if not (test, 'test') in test_list:
if (test, 'test') not in test_list:
error("no such test: " + test)

if args.demo:
if not (args.demo[0], 'demo') in test_list:
if (args.demo[0], 'demo') not in test_list:
error("no such demo: " + args.demo[0])

return test_list
Expand Down
3 changes: 2 additions & 1 deletion openage/util/bytequeue.py
Expand Up @@ -190,7 +190,7 @@ def get_buffers(self, start, end):
start = max(start, 0)
end = min(end, len(self))

if not end > start:
if end <= start:
yield b""
return

Expand All @@ -203,6 +203,7 @@ def get_buffers(self, start, end):

# cut off superfluous parts at the left of the first buffer.
# the negative index is intentional.
# pylint: disable=unsubscriptable-object
buf = buf[start - self.index[idx]:]

remaining = end - start
Expand Down
5 changes: 3 additions & 2 deletions openage/util/filelike.py
Expand Up @@ -5,12 +5,13 @@
interface, and various classes that implement the interface.
"""

from .bytequeue import ByteQueue, ByteBuffer
from abc import ABC, abstractmethod
from io import UnsupportedOperation
from .math import INF, clamp
import os

from .bytequeue import ByteQueue, ByteBuffer
from .math import INF, clamp


class FileLikeObject(ABC):
"""
Expand Down
4 changes: 4 additions & 0 deletions openage/util/struct.py
Expand Up @@ -130,7 +130,9 @@ def __init__(self, data):
"struct fields")

for name, value in zip(self._attributes, values):
# pylint: disable=unsupported-membership-test
if name in self._postprocessors:
# pylint: disable=unsubscriptable-object
value = self._postprocessors[name](value)

setattr(self, name, value)
Expand Down Expand Up @@ -178,12 +180,14 @@ def __getitem__(self, index):
"""
Returns the n-th field, or raises IndexError.
"""
# pylint: disable=unsubscriptable-object
return getattr(self, self._attributes[index])

def as_dict(self):
"""
Returns a key-value dict for all attributes.
"""
# pylint: disable=not-an-iterable
return {attr: getattr(self, attr) for attr in self._attributes}

def __iter__(self):
Expand Down

0 comments on commit 84a61f9

Please sign in to comment.