Disabling warnings per file

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sygi

I am using some code that I don’t want to modify (webrtc example server). It causes a number of warnings that I want to disable only for this file and not for the whole project.

Following this tutorial, I tried placing:

# warnings-disable

and the top of the file

# warning-ignore:shadowed_variable

above the line causing the warning, to no avail. Is there a different way for silencing the errors in GDScript 4?

:bust_in_silhouette: Reply From: jgodfrey

The warning suppression syntax has changed in Godot 4, but it looks like the docs haven’t been updated yet. There is a PR here to do just that.

If you let the editor insert an ignore clause for you (via the yellow warning triangle at the bottom-right edge of the the code panel) you can see the new syntax. Here’s an example to ignore an unused parameter:


That said, I’m not sure what the new equivalent of the file-level # warnings-disable is (it’s not mentioned in the above linked PR).