forked from fluidattacks/makes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(back): fluidattacks#1168 python vscode settings
- adjust python docs - add makePythonVscodeSettings util - fix pythonOverrideUtils compose Signed-off-by: Daniel F. Murcia Rivera <danmur97@outlook.com>
- Loading branch information
Showing
6 changed files
with
237 additions
and
52 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
__nixpkgs__, | ||
makeTemplate, | ||
... | ||
}: | ||
{ | ||
name, | ||
env, | ||
bins, | ||
}: | ||
makeTemplate { | ||
inherit name; | ||
searchPaths = { | ||
bin = | ||
bins | ||
++ [ | ||
env | ||
]; | ||
}; | ||
replace = { | ||
__argPython__ = __nixpkgs__.python310; | ||
__argPythonEnv__ = env; | ||
__argPythonEntry__ = ./vs_settings.py; | ||
}; | ||
template = ./template.sh; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# shellcheck shell=bash | ||
|
||
mkdir -p ./.vscode \ | ||
&& "__argPython__"/bin/python "__argPythonEntry__" ./.vscode/settings.json "__argPythonEnv__" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from json import ( | ||
dump, | ||
load, | ||
) | ||
from pathlib import ( | ||
Path, | ||
) | ||
import sys | ||
from typing import ( | ||
Tuple, | ||
) | ||
|
||
|
||
def set_settings(settings_path: Path, python_env: Path) -> None: | ||
settings_path.touch(exist_ok=True) | ||
env_settings = { | ||
"python.pythonPath": (python_env / "bin/python").as_posix(), | ||
"python.defaultInterpreterPath": ( | ||
python_env / "bin/python" | ||
).as_posix(), | ||
"mypy.dmypyExecutable": (python_env / "bin/dmypy").as_posix(), | ||
"python.linting.pylintPath": (python_env / "bin/pylint").as_posix(), | ||
"python.testing.pytestArgs": ["tests"], | ||
"python.testing.unittestEnabled": False, | ||
"python.testing.pytestEnabled": True, | ||
"python.linting.enabled": True, | ||
"python.linting.mypyEnabled": False, | ||
"python.linting.pylintEnabled": True, | ||
} | ||
with open(settings_path, "r+", encoding="UTF-8") as file: | ||
if file.read() == "": | ||
settings = {} | ||
else: | ||
file.seek(0) | ||
settings = load(file) # type: ignore[misc] | ||
with open(settings_path, "w+", encoding="UTF-8") as file: | ||
new_settings = settings | env_settings | ||
dump(new_settings, file, indent=2) | ||
|
||
|
||
def main(args: Tuple[str, ...]) -> None: | ||
settings = Path(args[1]) | ||
env = Path(args[2]) | ||
if env.exists(): | ||
set_settings(settings, env) | ||
else: | ||
raise Exception(f"Non existent env: {env}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main(tuple(sys.argv)) |
This file contains 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