Skip to content

Commit 41be996

Browse files
author
Omar WALDMANN
authored
Merge pull request #2 from fbessou/master
Make compatible with Pylint 2.1.1 and Python 3
2 parents 890cd42 + bac0781 commit 41be996

File tree

6 files changed

+8
-5
lines changed

6 files changed

+8
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ Available versions :
2525
- Version 1.0 - compatible pylint 1.5
2626
- Version 2.0 - compatible pylint 1.6
2727
- Version 3.0 - compatible pylint 1.7.4
28+
- Version 4.0 - compatible pylint 2.1.1

checkers/cnes_checker.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from pylint.checkers.utils import check_messages
2828
from pylint.checkers.raw_metrics import get_type
2929
from pylint.utils import WarningScope
30+
import tokenize
3031

3132

3233
class DesignChecker(BaseChecker):
@@ -100,7 +101,7 @@ def visit_call(self, node):
100101
if funcdef.name == 'open':
101102
parent = funcdef.parent
102103
if (isinstance(parent, astroid.Module)
103-
and parent.name == '__builtin__'):
104+
and parent.name == '_io'):
104105
if not isinstance(node.parent, astroid.With):
105106
self.add_message('use-context-manager', node=node,
106107
args='opening the file')
@@ -216,6 +217,8 @@ def process_tokens(self, tokens):
216217
"""update stats"""
217218
i = 0
218219
tokens = list(tokens)
220+
if tokens[0].type == tokenize.ENCODING:
221+
i = 1
219222
tail = None
220223
while i < len(tokens):
221224
start_line = tokens[i][2][0]

test/functional/builtin_name_used.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class MyClass(object):
55
def __init__(self):
6-
((self.file, (self.str, self.something)), plop) = (('test.txt', 'hello'), 'plop') # [builtin-name-used, builtin-name-used]
6+
((self.str, self.something), plop) = (('test.txt', 'hello'), 'plop') # [builtin-name-used]
77

88
bool = True # [builtin-name-used]
99

test/functional/builtin_name_used.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
builtin-name-used:6:MyClass.__init__:file is named after a built-in, consider renaming it
21
builtin-name-used:6:MyClass.__init__:str is named after a built-in, consider renaming it
32
builtin-name-used:8:MyClass:bool is named after a built-in, consider renaming it
43
builtin-name-used:10:MyClass.map:map is named after a built-in, consider renaming it

test/functional/os_environ_used.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
def function1():
1010
a = os.environ # [os-environ-used]
1111

12-
print e # [os-environ-used]
12+
print(e) # [os-environ-used]
1313
env = o.getenv() # [os-environ-used]
1414
o.putenv('TOTO', 'titi') # [os-environ-used]
1515
sep = o.sep

test/functional/sys_argv_used.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
def function1():
1010
a = s.argv[0] # [sys-argv-used]
1111

12-
print a # [sys-argv-used]
12+
print(a) # [sys-argv-used]
1313

1414
if len(sys.argv > 1): # [sys-argv-used]
1515
param = sys.argv[1] # [sys-argv-used]

0 commit comments

Comments
 (0)