Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • S system-design-primer
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 173
    • Issues 173
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 190
    • Merge requests 190
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Donne Martin
  • system-design-primer
  • Issues
  • #148
Closed
Open
Issue created Mar 14, 2018 by Administrator@rootContributor

Where is 'State' defined in social_graph_snippets.py?

Created by: cclauss

State is currently an undefined name in the context of social_graph_snippets.py so the code would raise a NameError at runtime.

Is State merely an Enum with two items (visited and unvisited) or is it more complex than that? If it is just the simple Enum then perhaps it would be cleaner to rename the field to be source.state_visited and use the values True and False.

flake8 testing of https://github.com/donnemartin/system-design-primer on Python 3.6.3

$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics

./solutions/system_design/social_graph/social_graph_snippets.py:10:30: F821 undefined name 'State'
        source.visit_state = State.visited
                             ^
./solutions/system_design/social_graph/social_graph_snippets.py:17:49: F821 undefined name 'State'
                if adjacent_node.visit_state == State.unvisited:
                                                ^
./solutions/system_design/social_graph/social_graph_snippets.py:19:49: F821 undefined name 'State'
                    adjacent_node.visit_state = State.visited
                                                ^
3    F821 undefined name 'State'

Discovered via #93

Assignee
Assign to
Time tracking