Created
January 17, 2022 18:14
-
-
Save brumar/76e0b9bf39acd491bbf05650e5757ba9 to your computer and use it in GitHub Desktop.
fix pyannotate annotations by changing relative paths to absolute paths
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| from pathlib import Path | |
| if __name__ == "__main__": | |
| dico = json.load(Path("./annotations.json").open()) | |
| for element in dico: | |
| element["path"] = str(Path(__file__).parent) + "/" + element["path"] | |
| json.dump(dico, Path("./annotations_2.json").open("w")) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very often I get "No files need to be modified" when the annotation files generated by pyannotate contains many annotations. This is probably related to my usage of pytest-annotate that does not mesh well with pyannotate. I don't know the root cause to be honest. This gist produce a file named
annotations_2.jsonthat have absolute paths in it, so that mypyannotate --type-info ./annotations_2.json --py3 -p -w .work at last.