Fix stacklevel flake8 warning
Some lines in the code make flake8 throw the following warning:
B028: No explicit stacklevel keyword argument found. The warn method from the warnings module uses a stacklevel of 1 by default. This will only show a stack trace for the line on which the warn method is called. It is therefore recommended to use a stacklevel of 2 or greater to provide more information to the user.
Solve this issue by setting the the stacklevel explicitly