Skip to content

Commit

Permalink
create basedpyright pypi package that bundles pyright and the langaug…
Browse files Browse the repository at this point in the history
…e server with it
  • Loading branch information
DetachHead committed Jan 15, 2024
1 parent 42a19d8 commit 037962e
Show file tree
Hide file tree
Showing 13 changed files with 712 additions and 5 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,8 @@ junit.xml
.DS_Store
Thumbs.db

# Potential venv
.venv
# python stuff
.pdm-python
.pyprojectx
**/__pycache__
/.venv/
12 changes: 11 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
"esbenp.prettier-vscode",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.pylint",
"ms-python.black-formatter",
"ms-python.mypy-type-checker",
"charliermarsh.ruff",
"shd101wyy.markdown-preview-enhanced",
"mhutchie.git-graph",
"tamasfe.even-better-toml",
"redhat.vscode-yaml"
]
}
49 changes: 47 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,54 @@
"editor.formatOnSave": true
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "explicit"
"source.fixAll.eslint": "always",
"source.organizeImports": "always"
},
"typescript.tsdk": "node_modules/typescript/lib",
"python.languageServer": "None",
"editor.formatOnSave": true,
"git.allowForcePush": true,
"git.autofetch": "all",
"git.autoStash": true,
"git.pruneOnFetch": true,
"git.rebaseWhenSync": true,
"git.suggestSmartCommit": false,
"git.supportCancellation": true,
"git.useEditorAsCommitInput": false,
"diffEditor.ignoreTrimWhitespace": false,
"terminal.integrated.persistentSessionReviveProcess": "never",
"mypy-type-checker.args": ["--ide", "--python-version", "3.8"],
"mypy-type-checker.importStrategy": "fromEnvironment",
"files.autoSave": "onFocusChange",
"search.useIgnoreFiles": true,
"git.useCommitInputAsStashMessage": true,
"files.eol": "\n",
"python.testing.pytestEnabled": true,
"testing.automaticallyOpenPeekView": "never",
"python.analysis.typeCheckingMode": "off",
"python.analysis.autoFormatStrings": true,
"python.analysis.gotoDefinitionInStringLiteral": true,
"python.analysis.typeshedPaths": ["./.venv/lib/site-packages/mypy/typeshed"],
"pylint.importStrategy": "fromEnvironment",
"pylint.severity": {
"convention": "Warning",
"error": "Error",
"fatal": "Error",
"refactor": "Warning",
"warning": "Warning",
"info": "Warning"
},
"black-formatter.importStrategy": "fromEnvironment",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"yaml.schemas": {
"https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json": ".github/workflows/*.yaml"
},
"explorer.compactFolders": false,
"search.exclude": {
"pw": true
},
"mypy-type-checker.ignorePatterns": ["pw"],
"python.terminal.activateEnvInCurrentTerminal": true
}
80 changes: 80 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,86 @@
}
}
}
},
{
"label": "pdm install requirements",
"type": "shell",
"command": "./pw",
"args": ["install"],
"presentation": {
"clear": true
},
"problemMatcher": []
},
{
"label": "pdm update lockfile",
"type": "shell",
"command": "./pw",
"args": ["pdm", "update"],
"presentation": {
"clear": true
},
"problemMatcher": []
},
{
"label": "pdm refresh lockfile (no update)",
"type": "shell",
"command": "./pw",
"args": ["pdm", "lock", "--refresh"],
"presentation": {
"clear": true
},
"problemMatcher": []
},
{
"label": "basedmypy - all files",
"type": "shell",
"command": "./pw",
"args": ["pdm", "run", "mypy_all"],
"presentation": {
"clear": true
},
"problemMatcher": []
},
{
"label": "ruff - all files",
"type": "shell",
"command": "${command:python.interpreterPath}",
"args": ["-m", "ruff", "."],
"presentation": {
"clear": true
},
"problemMatcher": []
},
{
"label": "ruff fix - all files",
"type": "shell",
"command": "${command:python.interpreterPath}",
"args": ["-m", "ruff", "--fix", "."],
"presentation": {
"clear": true
},
"problemMatcher": []
},
{
"label": "pylint - all files",
"type": "shell",
"command": "${command:python.interpreterPath}",
"args": ["-m", "pylint", "basedpyright", "tests"],
"presentation": {
"clear": true
},
"problemMatcher": []
},
{
"label": "black - all files",
"type": "shell",
"command": "${command:python.interpreterPath}",
"args": ["-m", "black", "--color", "."],
"presentation": {
"clear": true
},
"problemMatcher": []
}
]
}
Empty file added basedpyright/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions basedpyright/langserver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from __future__ import annotations

from basedpyright.run_node import run


def main():
run("pyright-langserver")
7 changes: 7 additions & 0 deletions basedpyright/pyright.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from __future__ import annotations

from basedpyright.run_node import run


def main():
run("pyright")
10 changes: 10 additions & 0 deletions basedpyright/run_node.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from __future__ import annotations

import sys
from pathlib import Path

from nodejs import node


def run(script_name: str):
node.run([Path(__file__).parent / f"dist/{script_name}.js", *sys.argv[1:]])
24 changes: 24 additions & 0 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions pdm_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from __future__ import annotations

from pathlib import Path
from shutil import copytree

from nodejs import npm

if not Path("node_modules").exists():
npm.run(["ci"], check=True)
npm.run(["run", "build:cli:dev"], check=True)

pyright_npm_package_dir = Path("packages/pyright")
pyright_pypi_package_dir = Path("basedpyright")
copytree("packages/pyright/dist", "basedpyright/dist", dirs_exist_ok=True)
Loading

0 comments on commit 037962e

Please sign in to comment.