|
56 | 56 | import tokenize
|
57 | 57 | import warnings
|
58 | 58 |
|
59 |
| -try: |
60 |
| - from functools import lru_cache |
61 |
| -except ImportError: |
62 |
| - def lru_cache(maxsize=128): # noqa as it's a fake implementation. |
63 |
| - """Does not really need a real a lru_cache, it's just |
64 |
| - optimization, so let's just do nothing here. Python 3.2+ will |
65 |
| - just get better performances, time to upgrade? |
66 |
| - """ |
67 |
| - return lambda function: function |
68 |
| - |
69 | 59 | from fnmatch import fnmatch
|
| 60 | +from functools import lru_cache |
70 | 61 | from optparse import OptionParser
|
71 | 62 |
|
72 | 63 | try:
|
@@ -301,12 +292,6 @@ def maximum_line_length(physical_line, max_line_length, multiline,
|
301 | 292 | (len(chunks) == 2 and chunks[0] == '#')) and \
|
302 | 293 | len(line) - len(chunks[-1]) < max_line_length - 7:
|
303 | 294 | return
|
304 |
| - if hasattr(line, 'decode'): # Python 2 |
305 |
| - # The line could contain multi-byte characters |
306 |
| - try: |
307 |
| - length = len(line.decode('utf-8')) |
308 |
| - except UnicodeError: |
309 |
| - pass |
310 | 295 | if length > max_line_length:
|
311 | 296 | return (max_line_length, "E501 line too long "
|
312 | 297 | "(%d > %d characters)" % (length, max_line_length))
|
@@ -1459,12 +1444,6 @@ def comparison_type(logical_line, noqa):
|
1459 | 1444 |
|
1460 | 1445 | Okay: if isinstance(obj, int):
|
1461 | 1446 | E721: if type(obj) is type(1):
|
1462 |
| -
|
1463 |
| - When checking if an object is a string, keep in mind that it might |
1464 |
| - be a unicode string too! In Python 2.3, str and unicode have a |
1465 |
| - common base class, basestring, so you can do: |
1466 |
| -
|
1467 |
| - Okay: if isinstance(obj, basestring): |
1468 | 1447 | """
|
1469 | 1448 | match = COMPARE_TYPE_REGEX.search(logical_line)
|
1470 | 1449 | if match and not noqa:
|
@@ -1787,12 +1766,6 @@ def maximum_doc_length(logical_line, max_doc_length, noqa, tokens):
|
1787 | 1766 | if prev_token is None or prev_token in SKIP_TOKENS:
|
1788 | 1767 | lines = line.splitlines()
|
1789 | 1768 | for line_num, physical_line in enumerate(lines):
|
1790 |
| - if hasattr(physical_line, 'decode'): # Python 2 |
1791 |
| - # The line could contain multi-byte characters |
1792 |
| - try: |
1793 |
| - physical_line = physical_line.decode('utf-8') |
1794 |
| - except UnicodeError: |
1795 |
| - pass |
1796 | 1769 | if start[0] + line_num == 1 and line.startswith('#!'):
|
1797 | 1770 | return
|
1798 | 1771 | length = len(physical_line)
|
|
0 commit comments