Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Side by Side Diff: third_party/logilab/astroid/mixins.py

Issue 753543006: pylint: upgrade to 1.4.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/logilab/astroid/manager.py ('k') | third_party/logilab/astroid/modutils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr 2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
3 # 3 #
4 # This file is part of astroid. 4 # This file is part of astroid.
5 # 5 #
6 # astroid is free software: you can redistribute it and/or modify it 6 # astroid is free software: you can redistribute it and/or modify it
7 # under the terms of the GNU Lesser General Public License as published by the 7 # under the terms of the GNU Lesser General Public License as published by the
8 # Free Software Foundation, either version 2.1 of the License, or (at your 8 # Free Software Foundation, either version 2.1 of the License, or (at your
9 # option) any later version. 9 # option) any later version.
10 # 10 #
11 # astroid is distributed in the hope that it will be useful, but 11 # astroid is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14 # for more details. 14 # for more details.
15 # 15 #
16 # You should have received a copy of the GNU Lesser General Public License along 16 # You should have received a copy of the GNU Lesser General Public License along
17 # with astroid. If not, see <http://www.gnu.org/licenses/>. 17 # with astroid. If not, see <http://www.gnu.org/licenses/>.
18 """This module contains some mixins for the different nodes. 18 """This module contains some mixins for the different nodes.
19 """ 19 """
20 20
21 from logilab.common.decorators import cachedproperty
22
21 from astroid.exceptions import (AstroidBuildingException, InferenceError, 23 from astroid.exceptions import (AstroidBuildingException, InferenceError,
22 NotFoundError) 24 NotFoundError)
23 25
24 26
25 class BlockRangeMixIn(object): 27 class BlockRangeMixIn(object):
26 """override block range """ 28 """override block range """
27 def set_line_info(self, lastchild): 29
28 self.fromlineno = self.lineno 30 @cachedproperty
29 self.tolineno = lastchild.tolineno 31 def blockstart_tolineno(self):
30 self.blockstart_tolineno = self._blockstart_toline() 32 return self.lineno
31 33
32 def _elsed_block_range(self, lineno, orelse, last=None): 34 def _elsed_block_range(self, lineno, orelse, last=None):
33 """handle block line numbers range for try/finally, for, if and while 35 """handle block line numbers range for try/finally, for, if and while
34 statements 36 statements
35 """ 37 """
36 if lineno == self.fromlineno: 38 if lineno == self.fromlineno:
37 return lineno, lineno 39 return lineno, lineno
38 if orelse: 40 if orelse:
39 if lineno >= orelse[0].fromlineno: 41 if lineno >= orelse[0].fromlineno:
40 return lineno, orelse[-1].tolineno 42 return lineno, orelse[-1].tolineno
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 modname = self.modname 100 modname = self.modname
99 # XXX we should investigate deeper if we really want to check 101 # XXX we should investigate deeper if we really want to check
100 # importing itself: modname and mymodule.name be relative or absolute 102 # importing itself: modname and mymodule.name be relative or absolute
101 if mymodule.relative_to_absolute_name(modname, level) == mymodule.name: 103 if mymodule.relative_to_absolute_name(modname, level) == mymodule.name:
102 # FIXME: we used to raise InferenceError here, but why ? 104 # FIXME: we used to raise InferenceError here, but why ?
103 return mymodule 105 return mymodule
104 try: 106 try:
105 return mymodule.import_module(modname, level=level) 107 return mymodule.import_module(modname, level=level)
106 except AstroidBuildingException: 108 except AstroidBuildingException:
107 raise InferenceError(modname) 109 raise InferenceError(modname)
108 except SyntaxError, ex: 110 except SyntaxError as ex:
109 raise InferenceError(str(ex)) 111 raise InferenceError(str(ex))
110 112
111 def real_name(self, asname): 113 def real_name(self, asname):
112 """get name from 'as' name""" 114 """get name from 'as' name"""
113 for name, _asname in self.names: 115 for name, _asname in self.names:
114 if name == '*': 116 if name == '*':
115 return asname 117 return asname
116 if not _asname: 118 if not _asname:
117 name = name.split('.', 1)[0] 119 name = name.split('.', 1)[0]
118 _asname = name 120 _asname = name
119 if asname == _asname: 121 if asname == _asname:
120 return name 122 return name
121 raise NotFoundError(asname) 123 raise NotFoundError(asname)
122 124
OLDNEW
« no previous file with comments | « third_party/logilab/astroid/manager.py ('k') | third_party/logilab/astroid/modutils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698