Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

redefined_argument_from_local.py 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # pylint: disable=missing-docstring, unused-variable, unused-argument
  2. # pylint: disable=redefined-outer-name, invalid-name, redefine-in-handler
  3. def test_redefined_in_with(name):
  4. with open('something') as name: # [redefined-argument-from-local]
  5. pass
  6. with open('something') as (second, name): # [redefined-argument-from-local]
  7. pass
  8. with open('something') as (second, (name, third)): # [redefined-argument-from-local]
  9. pass
  10. other = None
  11. with open('something') as other:
  12. pass
  13. def test_not_redefined_in_with(name):
  14. with open('something') as test_redefined_in_with:
  15. pass
  16. def test_redefined_in_for(name):
  17. for name in []: # [redefined-argument-from-local]
  18. pass
  19. for (name, is_) in []: # [redefined-argument-from-local]
  20. pass
  21. for (is_, (name, _)) in []: # [redefined-argument-from-local]
  22. pass
  23. for _ in []:
  24. pass
  25. def test_not_redefined_in_for(name):
  26. for name_1 in []:
  27. pass
  28. # This one can be okay if you are interested in the last value
  29. # of the iteration
  30. other = None
  31. for other in []:
  32. pass
  33. def test_redefined_in_except_handler(name):
  34. try:
  35. 1 / 0
  36. except ZeroDivisionError as name: # [redefined-argument-from-local]
  37. pass
  38. def test_not_redefined_in_except_handler(name):
  39. try:
  40. 1 / 0
  41. except ZeroDivisionError as test_redefined_in_except_handler:
  42. pass
  43. def test_not_redefined(name):
  44. if not name:
  45. name = ''