IndentationError and undefined names
cclauss opened this issue · 6 comments
flake8 testing of https://github.com/apachecn/LeetCode on Python 3.7.0
$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
./docs/Leetcode_Solutions/Summarization/python_base.py:6:4: E999 IndentationError: unexpected indent
dir(obj) # 简单的列出对象obj所包含的方法名称,返回一个字符串列表
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:14:11: F821 undefined name 'matrix'
row = len(matrix)
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:15:11: F821 undefined name 'matrix'
col = len(matrix[0]) if row else 0
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:38:4: F821 undefined name 'key'
if key in D:
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:39:5: F821 undefined name 'key'
D[key].append(1)
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:41:5: F821 undefined name 'key'
D[key] = []
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:45:1: F821 undefined name 'string'
string[::-1]
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:47:10: F821 undefined name 'string'
"".join([string].reverse())
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:56:16: F821 undefined name 'heap'
heapq.heappush(heap, item) # 把item添加到heap中(heap是一个列表)
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:56:22: F821 undefined name 'item'
heapq.heappush(heap, item) # 把item添加到heap中(heap是一个列表)
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:58:15: F821 undefined name 'heap'
heapq.heappop(heap) # 把堆顶元素弹出,返回的就是堆顶
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:60:19: F821 undefined name 'heap'
heapq.heappushpop(heap, item) # 先把item加入到堆中,然后再pop,比heappush()再heappop()要快得多
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:60:25: F821 undefined name 'item'
heapq.heappushpop(heap, item) # 先把item加入到堆中,然后再pop,比heappush()再heappop()要快得多
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:62:19: F821 undefined name 'heap'
heapq.heapreplace(heap, item) # 先pop,然后再把item加入到堆中,比heappop()再heappush()要快得多
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:62:25: F821 undefined name 'item'
heapq.heapreplace(heap, item) # 先pop,然后再把item加入到堆中,比heappop()再heappush()要快得多
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:64:15: F821 undefined name 'x'
heapq.heapify(x) # 将列表x进行堆调整,默认的是小顶堆
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:66:14: F821 undefined name 'iterables'
heapq.merge(*iterables) # 将多个列表合并,并进行堆调整,返回的是合并后的列表的迭代器
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:68:16: F821 undefined name 'n'
heapq.nlargest(n, iterable, key=None) # 返回最大的n个元素(Top-K问���)
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:68:19: F821 undefined name 'iterable'
heapq.nlargest(n, iterable, key=None) # 返回最大的n个元素(Top-K问题)
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:70:17: F821 undefined name 'n'
heapq.nsmallest(n, iterable, key=None) # 返回最小的n个元素(Top-K问题)
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:70:20: F821 undefined name 'iterable'
heapq.nsmallest(n, iterable, key=None) # 返回最小的n个元素(Top-K问题)
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:98:16: F821 undefined name 'n'
for i in range(n):
^
./docs/Leetcode_Solutions/Summarization/Python刷题技巧笔记.py:100:3: F821 undefined name 'a'
a[~i] = 1
^
1 E999 IndentationError: unexpected indent
22 F821 undefined name 'matrix'
23
Thanks for the issue, I have fixed this, could you please retry the flake test and see if it works?
Nice! All are fixed except the very first one, the IndentationError.
You can test locally by doing:
python3 -m pip install flake8 # This only needs to be done once.
python3 -m flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
flake8 testing of https://github.com/apachecn/LeetCode on Python 3.7.0
$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
./docs/Leetcode_Solutions/Summarization/python_base.py:6:4: E999 IndentationError: unexpected indent
dir(obj) # 简单的列出对象obj所包含的方法名称,返回一个字符串列表
^
1 E999 IndentationError: unexpected indent
1
Well, can you provide me Number of the line of the very beginning one?
Line 6...
flake8 testing of https://github.com/apachecn/LeetCode on Python 3.7.0
$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
./docs/Leetcode_Solutions/Summarization/python_base.py:6:4: E999 IndentationError: unexpected indent
dir(obj) # 简单的列出对象obj所包含的方法名称,返回一个字符串列表
^
1 E999 IndentationError: unexpected indent
1
All done! If you agree with this, we may close this issue.
Nice work!