titibs29 / API_LED_PY

Re-defined variable from outer scope PYL-W0621
Anti-pattern
Major
4 months agoa year old
Redefining name 'pin' from outer scope (line 77)
50
51
52@app.get('/switch/<pin:int>')
53def switch(pin):54    if not pin:
55        abort(code=404, text="pin not provided")
56    if pin not in pins:
Redefining name 'pin' from outer scope (line 77)
38
39
40@app.get('/get/<pin:int>')
41def get(pin):42    if pin not in pins:
43        abort(code=404, text="pin useless")
44    return str(states.get(pin))
Redefining name 'pin' from outer scope (line 77)
27    if state not in (1,0):
28        abort(code=404, text= "invalid state "+str(state))
29    gpio.output(pins, state)
30    for pin in states:31        states[pin] = state
32    return "all pins changed to "+str(state)
33
Redefining name 'pin' from outer scope (line 77)
12
13
14@app.route('/set/<pin:int>/<state:int>')
15def set(pin, state):16    if pin not in pins:
17        abort(code=404, text="pin useless")
18    if state not in (1, 0):