Skip to content

Instantly share code, notes, and snippets.

@aryamansharda
Created March 5, 2022 05:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aryamansharda/4324c2435279324485ad11e05cbdda40 to your computer and use it in GitHub Desktop.
Save aryamansharda/4324c2435279324485ad11e05cbdda40 to your computer and use it in GitHub Desktop.
Checks staged files for ambiguous constraints
import sys
if __name__ == '__main__':
arguments = sys.argv
# The first parameter is always the call to this executable "python3 check-ambiguous-references" which we can drop
arguments.pop(0)
ambiguous_constraints_found = False
# Searches through all of the modified files looking for the introduction of ambiguous constraints
for argument in arguments:
file = open(argument, "r")
if "ambiguous=\"YES\"" in file.read():
sys.stdout.write("Ambiguous constraints found in " + file.name + "\n")
ambiguous_constraints_found = True
exit(1) if ambiguous_constraints_found else exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment