-
-
Notifications
You must be signed in to change notification settings - Fork 154
Fix issue #37 : Create my_path.pth only for local mypy test, remove afterwards #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
2ca61ab
1315ebb
a37d136
ccf6157
a10dfe0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,29 @@ | ||
| import shutil | ||
| import subprocess | ||
| from pathlib import Path | ||
| import sys | ||
|
|
||
| from scripts._job import Step, run_job | ||
|
|
||
| def create_mypy_pkg_file(): | ||
| pkg_path = [x for x in sys.path if x.endswith('site-packages')] | ||
|
|
||
| if not Path(fr'{pkg_path[0]}/my_path.pth').exists(): | ||
| with open(fr'{pkg_path[0]}/my_path.pth', 'w') as file: | ||
| file.write(str(Path.cwd())) | ||
|
|
||
|
|
||
| def destroy_mypy_pkg_file(): | ||
| pkg_path = [x for x in sys.path if x.endswith('site-packages')] | ||
|
|
||
| if Path(fr'{pkg_path[0]}/my_path.pth').exists(): | ||
| Path(fr'{pkg_path[0]}/my_path.pth').unlink() | ||
|
|
||
|
|
||
| def run_mypy_src(): | ||
| create_mypy_pkg_file() | ||
| cmd = ["mypy", "pandas-stubs", "tests", "--no-incremental"] | ||
| subprocess.run(cmd, check=True) | ||
| destroy_mypy_pkg_file() | ||
|
|
||
|
|
||
| def run_pyright_src(): | ||
|
|
@@ -31,24 +47,49 @@ def install_dist(): | |
| subprocess.run(cmd, check=True) | ||
|
|
||
|
|
||
| def add_last_changes(): | ||
|
||
| cmd = ["git", "add", "."] | ||
| subprocess.run(cmd, check=True) | ||
|
|
||
|
|
||
| def commit_last_changes(): | ||
| cmd = ["git", "commit", "-am", "\"temp commit\""] | ||
| subprocess.run(cmd, check=True) | ||
|
|
||
|
|
||
| def remove_src(): | ||
| shutil.rmtree(r"pandas-stubs") | ||
|
|
||
|
|
||
| def run_mypy_dist(): | ||
| create_mypy_pkg_file() | ||
|
||
| cmd = ["mypy", "tests", "--no-incremental"] | ||
| subprocess.run(cmd, check=True) | ||
| destroy_mypy_pkg_file() | ||
|
|
||
|
|
||
| def run_pyright_dist(): | ||
| cmd = ["pyright", "tests"] | ||
| subprocess.run(cmd, check=True) | ||
|
|
||
|
|
||
| def uninstall_dist(): | ||
| cmd = ["pip", "uninstall", "-y", "pandas-stubs"] | ||
| subprocess.run(cmd, check=True) | ||
|
|
||
|
|
||
| def restore_last_changes(): | ||
|
||
| cmd = ["git", "show", "-s", "--format=%s"] | ||
| process = subprocess.Popen(cmd, stdout=subprocess.PIPE) | ||
| last_commit_name = process.communicate()[0] | ||
|
|
||
| if last_commit_name == b'"temp commit"\n': | ||
| cmd = ["git", "reset", "--soft", "HEAD~1"] | ||
| subprocess.run(cmd, check=True) | ||
| else: | ||
| print("There is not temp commit to restore.") | ||
|
|
||
|
|
||
| def restore_src(): | ||
| cmd = ["git", "checkout", "HEAD", "pandas-stubs"] | ||
| subprocess.run(cmd, check=True) | ||
|
|
@@ -74,3 +115,6 @@ def create_new_venv(): | |
| cmd = ["poetry", "shell"] | ||
| subprocess.run(cmd, check=True) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| restore_last_changes() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If for some reason this fails, the file would still be there. Can't you use the
rollbacktechnique you have used elsewhere in case of failure?