You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enable strict mode, update docs, use internal Settings object
Updates the default pyre configuration to be strict,
and updates the documentation to match. Introduces an
internal settigs object, because I'm not a fan of
dicts and the typing thereof (yes, TypedDict exists).
* Introduces the Settings dataclass
* Uses it to convert the pylsp settings dict to a typed object
* Defaults pyre to strict mode when writing out the initial config file
* Updates the documentation to reflect this strict mode
* Updates the documentation to explain squelching of Pyre lints
* Adds source commentary about pyre's output vs LSP w.r.t. lints per file
* Bumps the version
Copy file name to clipboardexpand all lines: README.md
+28-6
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,14 @@ This is a plugin for the [Python LSP Server](https://github.com/python-lsp/pytho
4
4
5
5
It implements support for calling Meta's [Pyre type checker](https://github.com/facebook/pyre-check) via a subprocess.
6
6
7
+
Pyre does offer a language server of its own, and that may be more useful to you if your editor supports multiple language servers per language.
8
+
9
+
## Features
10
+
11
+
This plugin adds the following features to `python-lsp-server`:
12
+
13
+
- Type linting via Meta's Pyre (pyre-check)
14
+
7
15
## Installation
8
16
9
17
To use this plugin, you need to install this plugin in the same virtualenv as `python-lsp-server` itself.
@@ -43,19 +51,33 @@ The configuration written by this plugin is:
43
51
"exclude": [
44
52
"/setup.py",
45
53
".*/build/.*"
46
-
]
54
+
],
55
+
"strict": true
47
56
}
48
57
```
49
58
50
-
The noteable difference from `pyre init` is the change to the search strategy (pep561 to all).
59
+
The noteable difference from `pyre init` is the change to the search strategy ("pep561" to "all"), and turning on strict mode as the default. You may find strict mode a bit pedantic, but having worked with strict mode for several years, I highly recommend it.
51
60
52
-
If the file is not present, the LSP error log, LSP output, and your editor's LSP messages will display an ABEND message containing the error from Pyre as it fails to run.
61
+
If the `.pyre_configuration`file is not present (or has a syntax error), the LSP error log, LSP output, and your editor's LSP messages will display an ABEND message containing the error from Pyre as it fails to run.
53
62
54
-
## Features
63
+
## Squelching Pyre lint errors
55
64
56
-
This plugin adds the following features to `python-lsp-server`:
65
+
The recommended way of squelching a Pyre warning is to pick one of `# pyre-ignore` or `# pyre-fixme`. More precisely, suppose Pyre is indicating
57
66
58
-
- Type linting via Meta's Pyre (pyre-check)
67
+
```
68
+
Missing global annotation [5]: Globally accessible variable `logger` has type `logging.Logger` but no type is specified.
69
+
```
70
+
71
+
at you, and you do not feel like typing your logger right now. On the line before, you can put either one of
72
+
73
+
*`# pyre-ignore[5] Don't care about logger`
74
+
*`# pyre-fixme[5] Resolve this when doing all logger work`
75
+
76
+
to squelch the lint, and provide a hint to future you (or other readers of the code). This is a trivial example; it's easier to just type the logger.
77
+
78
+
You do not need to match the number in the brackets, other than for ease of cross-reference with the [type errors documentation](https://pyre-check.org/docs/errors/).
79
+
80
+
When you address the squelched error, Pyre will indicate that the comment is not suppressing a type error and can be removed.
0 commit comments