Where to report issues about Python syntax checking?

By misstake I made a variable assignment using two equal signs, like this code:

flag == True

This error was not notified by the syntax check, but totally ignored during execution of the program.
It happened several times and is easily repeated…
The Python version:
Python 3.10.12
Running Ubuntu 22.04 on an old 64-bit cpu laptop.

Surrounding code was like this :+1:

pix = pya.pixel(x, y)

print(“(” + str(x) + “,” + str(y) + ") " + str(pix))

				if pix[0] == 253 and pix[1] == 235 and pix[2] == 27:
					flag == True

print("line: " + str(tt.getlinenbr()) + " " + str(flag))

					break

print("line: " + str(tt.getlinenbr()) + " " + str(flag))

			if flag:
				break


Hope you can use this information
Tor chris

This can be caught using a linter, such as ruff --select B

4 Likes

Thanks for your response. I have not heard about linter. It seems great. I’m just a bit too naive to believe that Python would secure that compiling the script means that it could handle it.
So I’ll dig into linter :slight_smile: Thanks again .

The reason Python doesn’t complain is because it’s not a syntax error–maybe you did want to check if something was equal to True. So the script could indeed handle it just fine. Linters can check for common mistakes that are valid code but possibly logical errors in terms of what you wanted.

1 Like

Any expression can be used as a statement; primarily, this is so you can write

some_function()

instead of

dont_care = some_function()

but Python doesn’t try to enumerate the expressions that are useful as standalone statements and prohibit the rest.

Meh, x := 0 is an expression that needs some help.

Yeah, that’s a bit of a special case.