Tags: hockbase/pyre-check
Tags
distinguish instance attribute models from class attribute models Summary: In Python, the semantics of class and instance variables differ. If you declare `class C: x = 1` and write `self.x = 2` later, `C.x` will remain unchanged for the other instances of `C`. Previously, we would allow accessing an attribute model through both the instance and class. This disallows us from expressing models only for class attributes vs. only for instance attributes. Support the class attribute case via the module_name.ClassName.__class__.attribute, and keep instance attribute syntax as is (via module_name.ClassName.attribute). If we need models for both cases, we'll need to write both. Reviewed By: fahndrich Differential Revision: D16672643 fbshipit-source-id: 92ff7bcf0863514ab5da670ed6f9e8474e78799e
Remove special treatment for `@contextmanager` and `@asynccontextmana… …ger` Summary: We used to hard-code the behavior of `contextmanager` and `asynccontextmanager`. Problems are: - With D15011034 adding support for user-defined decorators we no longer need to special-case them. - Hard coding class names lead to sadness when the hardcoded name [changes in typeshed](python/typeshed@668d050) I also pulled the relevant classes from the helper stubs into `contextlib` stubs and replace them with the actual typeshed stubs. Reviewed By: shannonzhu, mrkmndz Differential Revision: D16166530 fbshipit-source-id: 9d5497dde51724b6e8772cef119e5bd4609f9d79
Adding first draft of subtyping rules Summary: This is a first draft at documenting the main component of the subtyping rule: `less_or_equal`. We still need `join` and `meet` to have a realistic package. The style is to write down the rules in the same order as the code. At some point we might want to change to a style with only "positive rules" (e.g. don't write anything about Top <= T, because if there is no rule to build it, we can't prove it). That might evolve in the future Reviewed By: dkgi Differential Revision: D16120038 fbshipit-source-id: ddc1ee5df934771e1d3185bf98f3cae04e4f292d
search for binary under virtualenv directory correctly Summary: A common workflow is to create a venv, thusly: ``` python3 -m venv /tmp/pyre /tmp/pyre/bin/pip install pyre-check /tmp/pyre/bin/pyre start ``` Now, since `/tmp/pyre/bin` isn't in $PATH, we would miss out on the binary. Make pyre initialize and pyre smarter, and try to pick up on these binaries. This use case is particularly pertinent in OSS development. Reviewed By: grievejia Differential Revision: D15178027 fbshipit-source-id: 938c9d5e82b23bad5986f51bcb90760a2a4b8156
only support opam 2.0 Summary: As mentioned in facebook#142, opam 1.2 doesn't have recent package versions, and is unable to build Pyre. Reviewed By: grievejia Differential Revision: D15133329 fbshipit-source-id: eef93a8b9965c7a862637e0dedcc3de532409ff4
Using basic type partitioning for more principled isinstance checking Summary: This diff extends the ideas of D14545445 to apply to more than the special case of lists, and to work in the positive case as well. The average case we're trying to support here looks like this: ``` x: Union[int, Set[int]] if isinstance(x, set): # the runtime disallows using a parametric type here, and pyre will correctly interpret it as Set[Any] # x should be known to be List[int] else: # x should be known to be int ``` In theory, the positive case should be inferred to be `Intersection[previous type, asserted type]` and the negative case to be `Difference[previous type, asserted type]`. Without supporting these types first class, we can approximate them by opening up the unions (and implicit unions like Optional), and doing element-wise comparisons with the boundary. In order to support types with Anys, we need to use `is_consistent_with` rather than normal `less_or_equal`. Reviewed By: sinancepel Differential Revision: D15060401 fbshipit-source-id: 656b63a51b62d07e21f2c1b8fc700ca15b94a739
Add new query option (1/n) Summary: Adds a new query option regarding coverage in files, to be used in follow up diffs to build the color tool. Reviewed By: sinancepel Differential Revision: D14739329 fbshipit-source-id: a685b553219a5a62c771aeac8ebf00f1926bda86
PreviousNext