Skip to content

Syntax error in ./preorder_iterative_bst.py #4

@cclauss

Description

@cclauss

flake8 testing of https://github.com/devAmoghS/Python-Interview-Problems-for-Practice on Python 3.7.1

$ flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics

./preorder_iterative_bst.py:9:47: E999 SyntaxError: invalid syntax
    stack.insert(0, right) if right is not None
                                              ^
./loop_in_linkedlist.py:17:15: F821 undefined name 'LinkedList'
linked_list = LinkedList()
              ^
./loop_in_linkedlist.py:19:7: F821 undefined name 'findMToLast'
print(findMToLast(linked_list))
      ^
./remove_duplicates_v2.py:10:10: F821 undefined name 'remove_duplicates'
result = remove_duplicates([0,0,0,1,1,2,2,3,4,5])
         ^
./find_m_to_last_llist.py:21:15: F821 undefined name 'LinkedList'
linked_list = LinkedList()
              ^
./dfs_bfs.py:20:9: F821 undefined name 'dfs'
        dfs(graph, next, visited)
        ^
./heap_structure.py:68:14: F821 undefined name 'self'
    result = self.heap[0]
             ^
./heap_structure.py:69:5: F821 undefined name 'self'
    self.currentPosition-=1
    ^
./heap_structure.py:70:5: F821 undefined name 'self'
    self.heap[0] = self.heap[self.currentPosition]
    ^
./heap_structure.py:70:20: F821 undefined name 'self'
    self.heap[0] = self.heap[self.currentPosition]
                   ^
./heap_structure.py:70:30: F821 undefined name 'self'
    self.heap[0] = self.heap[self.currentPosition]
                             ^
./heap_structure.py:71:9: F821 undefined name 'self'
    del self.heap[self.currentPosition]
        ^
./heap_structure.py:71:19: F821 undefined name 'self'
    del self.heap[self.currentPosition]
                  ^
./heap_structure.py:72:5: F821 undefined name 'self'
    self.fixDown(0, -1)
    ^
1     E999 SyntaxError: invalid syntax
13    F821 undefined name 'dfs'
14

E901,E999,F821,F822,F823 are the "showstopper" flake8 issues that can halt the runtime with a SyntaxError, NameError, etc. These 5 are different from most other flake8 issues which are merely "style violations" -- useful for readability but they do not effect runtime safety.

  • F821: undefined name name
  • F822: undefined name name in __all__
  • F823: local variable name referenced before assignment
  • E901: SyntaxError or IndentationError
  • E999: SyntaxError -- failed to compile a file into an Abstract Syntax Tree

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions