5 of 6 standards met
Summary: When a TypeVar has , pyrefly internally represents the bound as , which resolves to during attribute lookup. The quantified TypeVar attribute resolution only handled , causing any other variant (including ) to fall back to . This produced false positives like "Object of class has no attribute " when accessing attributes that exist on the class. The fix extracts the bound-to-ClassType mapping into a helper that handles both (the common case) and (the case, mapping to ). This is applied to all four sites where quantified bounds are resolved: both and paths, for both and restrictions. Fixes https://github.com/facebook/pyrefly/issues/2614 Differential Revision: D95419868
Repository: facebook/pyrefly. Description: A fast type checker and language server for Python Stars: 5432, Forks: 280. Primary language: Rust. Languages: Rust (85.4%), Python (9.3%), TypeScript (2.5%), MDX (2.3%), Shell (0.2%). License: MIT. Homepage: http://pyrefly.org/ Topics: code-quality, contributions-welcome, good-first-issue, hacktoberfest, ide, language-server, lsp, python, rust, type-check, type-checker, typecheck, typechecker, types, typing. Latest release: 0.55.0 (2d ago). Open PRs: 77, open issues: 407. Last activity: 2m ago. Community health: 87%. Top contributors: ndmitchell, stroxler, rchen152, yangdanny97, kinto0, migeed-z, connernilsen, grievejia, samwgoldman, dluo and others.
Rust
Last 12 weeks · 1856 commits
Summary Fixes part of #1589 The code action now adds type annotations for fixture parameters only in test functions, resolving fixtures first in the current module then upward to conftest files (closest wins). Haven't implemented full pytest fixture resolution outside conftest but the current approach covers typical use. But problem: should LSP just infer the version as inlay hint, then click to insert? relevant https://github.com/DetachHead/basedpyright/issues/311 Test Plan pytest_fixture_type_annotation_code_actions
Motivation: Currently, when you are working with a list comprehension like , the "Go to Definition" feature works for the variable after the for (the target ), but it fails and returns nothing if you try it on the variable before the for (the usage ). This PR fixes that bug so that clicking on the usage will correctly take you to where it is defined. Approach: The bug happens because of how the Pyrefly language server tries to follow the chain of variable references. For variables inside comprehensions, the chain goes through a special step called . The code that searches for definitions (find_definition_key_from in pyrefly/lib/state/ide.rs) did not know how to handle this step, so it would give up and return nothing. I updated the code to recognize as a valid stopping point. Now, when the search hits this point, it correctly returns the location of the variable. Tests: I added two tests in pyrefly/lib/test/lsp/definition.rs to make sure "Go to Definition" works for both parts of a list comprehension and to prevent this bug from coming back. I manually analyzed code bases and tested all the changes to make sure everything works correctly. Tests Screenshots
Describe the Bug Minimal repro: No other type checker has this behavior. Sandbox Link https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIAOlTZegOoAWM6ABKqwCqnEwBqqAE6tGqOO1Z4ArllYAKGIQDmhADSTcMzAF4ALjxgBKdWUEwwUUqzNxcUAG7x2u3YIjYpumHVQBjX-DiuGy6zFwGAsK6uKwABrjYAFYwvrqxrBDocF6omKy4YKyhMBpaRQaEXIwQ4r6oUnDwdGCoUI2sxLhwELoQjuIA7sxsfgFw3ehKzq7unk6hqLqsMPg1S8FFYdKy%2Brx0HkvouOts8UkpaYR01DdU6GCCuAC25cSZUxBPnYJL3LyR13QAGJwv8hKUdjFYrsYOkALRw9j%2BQLvOIAfTR6FQTxgGNidBB0IM6VE4g4sQxWJxeOmbgOMHUtlYvjahEp2NxaNYcEYmigeWwJXsrQgmAJrCGLC4GXE2zy0TiMNilQACqQzBYrDY7P1pWI4glkql0plsjBcld0JxWNpQfwhHJqJxqOo5XoDIY6JhzKwlDBdGiWWI4JiOXIWXBEFxDKw4QA%2BbmuRB0Vip6z%2BqSCNgRtmh6lc1gggBiKqjAHlzql8oUg%2BMDZW0iJ9UdabMvOi85z0iBVCBPNA4CRyIgQCCAKq9KA9KxgGSpCDBOCA72FMC4QRPRaYqRPQWCOT4KOZXQx%2BOJwTJthpsy6TNsMDUAByO73UeA%2BAAvjd0D2QKZzJYhDRE8UAUCCaoapY3IYDgBDMsEkBKJmiwLugloggAyjAJSMC4xCRgA9AR-6aoQ65KARLAEZguC%2BHABG%2BAhEBIYIKHBARrBrsIqDCtAqDYLA8H3MxyG9BsuDEGJWSWmQoTBHCjiCN0Gy2tQADMhAAIwAEzfiAH69n4vSOEW0AwBQaBYHgRBkPpQA (Only applicable for extension issues) IDE Information _No response_
Summary: Fix two related issues with enum pattern matching: 1. Issues #2080 and #2604: was not handled alongside in narrowing, subset checking, and overload expansion. This caused false-positive "non-exhaustive match" errors when matching on inside enum methods, and incorrect return types. 2. Circular dependency bug: resolved ALL class fields (including methods), creating a cycle when called during method body analysis of enum methods using . Added a flag to so that can skip methods and nested classes without resolving their types. Fixes https://github.com/facebook/pyrefly/issues/2080 Fixes https://github.com/facebook/pyrefly/issues/2604 Differential Revision: D95437784