I have created a Python package, let's call it 'mypackage'. There is a function in that package that does a check depending on a environment variable, and returns a boolean. That function is used in another function. Here is an example :
def check():
    if env_var == "value":
       return True
    return False
# check is used in foo
def foo():
    if check():
        raise PermissionError()
    else:
        return "foo"
My problem here is that the check function can be overwritten just by doing this
import mypackage
def other_func():
    return False
mypackage.check = other_func
How can I prevent a user from doing so, or make the "check" function unmodifiable ?