File: bug_type_reassignment.py

package info (click to toggle)
python-refurb 1.27.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,700 kB
  • sloc: python: 9,468; makefile: 40; sh: 6
file content (18 lines) | stat: -rw-r--r-- 513 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# See https://github.com/dosisod/refurb/issues/18 and https://github.com/dosisod/refurb/issues/53

# This is a regression test to make sure this code doesn't cause an error

x = "abc"
print(x)  # see below
x = 1
y = str(x)


# The print(x) line is needed because of the overly-strict "allow_redefinition"
# option in Mypy, which requires that a variable be read before it allows the
# creation of a new instance. The following code should fail, until Mypy fixes
# it (if they do).

x2 = "abc"
x2 = 1
y2 = str(x2)