diff --git a/.gitignore b/.gitignore index edd0a9568bc0..7936a109dc8b 100644 --- a/.gitignore +++ b/.gitignore @@ -60,7 +60,7 @@ analyze.py *~ .*.sw? .vscode/* -!.vscode/settings.default.json +!.vscode/settings.json !.vscode/extensions.json .idea/ .venv*/ diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 01b9ad4369db..c100a729cac8 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,4 @@ // ⚠ Disclaimer: The typeshed team doesn't commit to maintaining this file. It exists purely for your ease of use. -// Keep in alphabetical order { "recommendations": [ "bierner.github-markdown-preview", @@ -14,9 +13,6 @@ "redhat.vscode-yaml", ], "unwantedRecommendations": [ - /* - * Don't recommend by default for this workspace - */ "christian-kohler.npm-intellisense", /* * Must disable in this workspace @@ -32,10 +28,5 @@ "ms-python.autopep8", // Not using pylint "ms-python.pylint", - // VSCode has implemented an optimized version - "coenraads.bracket-pair-colorizer", - "coenraads.bracket-pair-colorizer-2", - // Obsoleted by Pylance - "ms-pyright.pyright", ], } diff --git a/.vscode/settings.default.json b/.vscode/settings.json similarity index 51% rename from .vscode/settings.default.json rename to .vscode/settings.json index b7005630a4e3..6d2afa78aa0e 100644 --- a/.vscode/settings.default.json +++ b/.vscode/settings.json @@ -1,110 +1,61 @@ /* - * Copy this file as `.vscode/settings.json` to configure VSCode for this workspace. - * Unfortunately, VSCode doesn't (yet) offer any way to have "workspace defaults" or "user-worspace settings", - * so offering defaults to copy is the best we can do at the moment. - * - * ⚠ Disclaimer: The typeshed team doesn't commit to maintaining this file. It exists purely for your ease of use. + * ⚠ Disclaimer: The typeshed team doesn't commit to maintaining this file. It exists purely for + * your ease of use. */ { - // Don't format on save for formatters we don't explicitely control - "editor.formatOnSave": false, - "editor.codeActionsOnSave": { - "source.fixAll": "never" - }, - // Set file associations to support comments syntax highlight - "files.associations": { - "settings.default.json": "jsonc", - "pyrightconfig*.json": "jsonc", - ".flake8": "properties", - "stubtest_allowlist*.txt": "properties", - "**/stubtest_allowlists/*.txt": "properties", - "pytype_exclude_list.txt": "properties" - }, - "files.exclude": { - "**/.*_cache": true, // mypy and Ruff cache - "**/__pycache__": true - }, - "files.eol": "\n", - "files.insertFinalNewline": true, - "files.trimFinalNewlines": true, - "files.trimTrailingWhitespace": true, - "editor.comments.insertSpace": true, - "editor.insertSpaces": true, - "editor.detectIndentation": false, - "editor.tabSize": 2, - "[json][jsonc][python][toml]": { - "editor.tabSize": 4 - }, - "editor.rulers": [ - 90, - 130 - ], "[git-commit]": { "editor.rulers": [ 72 ] }, - // Format on save for formatters we explicitely control - "[json][jsonc][yaml][python][toml]": { - "editor.formatOnSave": true, - "editor.codeActionsOnSave": { - "source.fixAll": "explicit" - } - }, "[json][jsonc]": { "editor.defaultFormatter": "vscode.json-language-features" }, - "[yaml]": { - "editor.defaultFormatter": "redhat.vscode-yaml" + "[json][jsonc][python][toml]": { + "editor.tabSize": 4 }, - "[toml]": { - "editor.rulers": [ - 90 - ], - "editor.defaultFormatter": "tamasfe.even-better-toml" + // The typeshed team recommends these extensions "fixAll" "OnSave" for your ease of use. + "[json][jsonc][yaml][python][toml]": { + "editor.codeActionsOnSave": { + "source.fixAll": "explicit" + }, + "editor.formatOnSave": true }, "[python]": { - "editor.rulers": [ - 130 - ], - "editor.defaultFormatter": "ms-python.black-formatter", "editor.codeActionsOnSave": { - // Let Ruff lint fixes handle imports + // The typeshed team recommends using Ruff for import statements. "source.organizeImports": "never", "source.unusedImports": "never" - } + }, + "editor.defaultFormatter": "ms-python.black-formatter", + "editor.rulers": [ + 130 + ] + }, + "[toml]": { + "editor.defaultFormatter": "tamasfe.even-better-toml", + "editor.rulers": [ + 90 + ] + }, + "[yaml]": { + "editor.defaultFormatter": "redhat.vscode-yaml" }, - // python.analysis is Pylance (pyright) configurations - "python.analysis.fixAll": [ - // Explicitly omiting "source.convertImportFormat", some stubs use relative imports - // Explicitly omiting "source.unusedImports", Let Ruff lint fixes handle imports - ], - "python.analysis.typeshedPaths": [ - "${workspaceFolder}" - ], - "python.analysis.extraPaths": [ - "tests" - ], - "mypy-type-checker.importStrategy": "fromEnvironment", - "mypy-type-checker.args": [ - "--custom-typeshed-dir=${workspaceFolder}", - // We only guarantee all of our tests can be run if you're on Python 3.9 or higher - "--python-version=3.9", - "--strict", - // Needed because a library stubbed in typeshed won't necessarily be installed in the dev's environment - "--ignore-missing-imports" - ], - // Ensure typeshed's configs are used, and not user's VSCode settings - "flake8.args": [ - "--config=.flake8" - ], - "flake8.importStrategy": "fromEnvironment", "black-formatter.importStrategy": "fromEnvironment", - // Using Ruff instead of isort - "isort.check": false, - "ruff.importStrategy": "fromEnvironment", - "ruff.fixAll": true, - "ruff.organizeImports": true, + "editor.codeActionsOnSave": { + "source.fixAll": "never" + }, + "editor.comments.insertSpace": true, + "editor.detectIndentation": false, + // The typeshed team recommends disabling generalized "on save" actions in favor of "on save" + // actions per extension. + "editor.formatOnSave": false, + "editor.insertSpaces": true, + "editor.rulers": [ + 90, + 130 + ], + "editor.tabSize": 2, "evenBetterToml.formatter.alignComments": false, "evenBetterToml.formatter.alignEntries": false, "evenBetterToml.formatter.allowedBlankLines": 1, @@ -119,7 +70,28 @@ "evenBetterToml.formatter.indentTables": false, "evenBetterToml.formatter.inlineTableExpand": false, "evenBetterToml.formatter.reorderArrays": true, + // "We" do not want you to reorder TOML keys because "we" like keeping TOML keys in a "specific + // non-alphabetical order" that feels more natural to "us". (Note: This file does not document + // the "specific non-alphabetical order", and this file does not identify who "we" are.) + "evenBetterToml.formatter.reorderKeys": false, "evenBetterToml.formatter.trailingNewline": true, - // We like keeping TOML keys in a certain non-alphabetical order that feels more natural - "evenBetterToml.formatter.reorderKeys": false + "files.eol": "\n", + "files.exclude": { + "**/__pycache__": true, + "**/.*_cache": true // This includes the mypy and Ruff caches. + }, + "files.insertFinalNewline": true, + "files.trimFinalNewlines": true, + "files.trimTrailingWhitespace": true, + "flake8.args": [ + "--config=.flake8 ${workspaceRoot}" + ], + // Using Ruff instead of isort + "isort.check": false, + "mypy-type-checker.args": [ + "--custom-typeshed-dir=${workspaceRoot}", + "--strict", + // A developer's environment might not have a library that typeshed provides a stub for. + "--ignore-missing-imports" + ], } diff --git a/typeshed.code-workspace b/typeshed.code-workspace new file mode 100644 index 000000000000..418fc48f4318 --- /dev/null +++ b/typeshed.code-workspace @@ -0,0 +1,25 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": { + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter" + }, + "files.associations": { + ".flake8": "properties", + "**/stubtest_allowlists/*.txt": "properties", + "pyrightconfig*.json": "jsonc", + "pytype_exclude_list.txt": "properties", + "settings.default.json": "jsonc", + "stubtest_allowlist*.txt": "properties" + }, + "flake8.importStrategy": "fromEnvironment", + "mypy-type-checker.importStrategy": "fromEnvironment", + "ruff.fixAll": true, + "ruff.importStrategy": "fromEnvironment", + "ruff.organizeImports": true, + } +}