facebook/pyrefly
62.4
Adequate · 14 November 2026
349.4k
lines of production code
Rust
with Python
5
measurements over time
What this system is
Features
Add JAX model examples with shape annotations
Added example implementations of BERT and NanoGPT models in JAX within the \jax-pyrefly-stubs\ directory. These examples demonstrate how to use JAX PyTrees with dataclasses and integrate with the project's shape extension system (\shape\_extensions\) to provide static type checking for tensor dimensions. The implementations include core layers like Linear, LayerNorm, and Attention, adapted to be deterministic and free of external framework dependencies to facilitate smoke testing.
jax-pyrefly-stubs · high confidence
Add PyTorch walltime benchmarks for cold start, error propagation, and full check
New benchmarks have been added to measure real-world LSP performance against a pinned PyTorch checkout. The suite includes a cold-start benchmark that measures the latency to the first cross-file go-to-definition, an error-propagation benchmark that measures incremental recheck latency when a type error is introduced in a heavily-imported file, a full-check benchmark that measures whole-project batch-check throughput, an indexed-memory benchmark for cold whole-project indexing time, and a workspace-symbol benchmark for warm symbol lookup latency. These benchmarks share a common harness that manages the PyTorch checkout (via internal resources or OSS git clone) and configures the LSP server to disable background workspace indexing to isolate the measured operations.
pyrefly/benches/pytorch · high confidence
Add Thrift schema definitions for Glean query results
Added \glean\_query\_types.thrift\ to define the data structures used for deserializing results from Glean Angle queries. This includes specific structs for \FindReferencesResult\ (containing File, ByteSpan, and Digest) and \WorkspaceSymbolResult\ (containing Name, File, Span, and Declaration), along with their underlying type definitions, enabling the system to correctly interpret query responses from the Glean backend.
pyrefly · high confidence
Add attrs field specifier binding logic
The bindings layer now includes dedicated logic to parse and validate attrs field specifiers (such as \@\<field\>.default\, \@\<field\>.validator\, and \@\<field\>.converter\) within class bodies. This change introduces a new \attrs.rs\ module that tracks these decorator methods, validates their signatures against attrs' positional calling conventions, and reports errors for invalid configurations, ensuring that attrs-specific metadata is correctly captured during the binding phase.
pyrefly/lib/binding · high confidence
Add benchmark harness for measuring fully-indexed memory usage and index entry counts
The \pyrefly\_bench\_harness\ crate now provides shared utilities to benchmark the memory footprint and index statistics of a fully indexed project. It introduces \index\_project\ to resolve and index files up to the \Require::Indexing\ level (matching the language server's background indexing), and \report\_indexed\_memory\ to output the resident set size (RSS) and specific find-references index entry counts (variable references, renamed imports, attribute references, constructor references, and parent methods) for a given corpus root. This allows developers to track memory consumption and index growth when the full reference index is active, rather than just during type checking.
_crates/pyrefly\_bench\harness · high confidence
Add bundled type stubs for botocore
Pyrefly now includes bundled type stubs for the botocore library, providing static type checking support for AWS SDK for Python (botocore). This addition covers core modules including authentication, client creation, configuration, credentials, and request handling, enabling better IDE support and type safety for users interacting with AWS services.
_crates/pyrefly\_bundled/third\party/stubs/botocore-stubs · high confidence
Add microtorch sandbox examples and type-checking infrastructure
Introduces a new microtorch module containing a minimal tensor model (microtorch.pyi) and shape extensions (shape\_extensions.pyi) designed to test Pyrefly's core shape behavior without depending on a real tensor library. This includes a suite of sandbox examples (overview, reference, setup, tutorial-basics) that demonstrate tensor operations like matrix multiplication, concatenation, and diagonal extraction, along with a test runner (run\_pyrefly.py) and test suites to validate these type-checking scenarios. Also in this area: 1 commit (0 fixes) modifying pyrefly-shape-extensions, tensor-shapes/microtorch.
tensor-shapes/microtorch · low confidence · unverified
Add numpy tensor-shape examples for physical science and statistics
New example files \physical\_science.py\ and \stats.py\ have been added to the \tensor-shapes/pyrefly-numpy-stubs/examples\ directory. These files demonstrate the use of the \shape\_extensions\ library (specifically \IntVar\ and \assert\_shape\) with NumPy arrays to verify tensor shapes in physical science simulations (e.g., harmonic oscillators, gravitational forces) and statistical algorithms (e.g., OLS, PCA, logistic regression).
tensor-shapes/pyrefly-numpy-stubs/examples · high confidence
Add shape-aware type stubs for NumPy
This change introduces a new \numpy-stubs\ package containing \.pyi\ stub files that provide shape-aware type information for NumPy. The stubs include a \py.typed\ marker file and define shape inference logic via a type-level DSL in \\_shapes.pyi\, enabling static type checkers to understand output shapes for operations like \matmul\, \reduce\, \stack\, and \expand\dims\. The \\\init\\.pyi\ re-exports core NumPy functions and types, while \random/\\init\\_.pyi\ adds specific shape-aware overloads for functions like \randn\. Also in this area: 1 commit (0 fixes) modifying tensor-shapes/pyrefly-numpy-stubs; 6 commits (0 fixes) modifying tensor-shapes/pyrefly-numpy-stubs/numpy-stubs.
tensor-shapes/pyrefly-numpy-stubs/numpy-stubs, tensor-shapes/pyrefly-numpy-stubs/numpy-stubs/random · medium confidence
Add shell completion generation and allocator configuration to the pyrefly binary
The pyrefly CLI now includes a \completion\ subcommand that generates shell completion scripts (e.g., for bash, zsh, fish) for its own argument tree, ensuring hidden commands and flags are excluded from the generated output while remaining functional when typed explicitly. Additionally, the binary configures memory allocators based on the target operating system: it uses jemalloc on Linux and macOS (unless built for fbcode) and mimalloc on Windows to optimize performance. The entrypoint also enables stack overflow backtraces in debug builds to aid in troubleshooting.
pyrefly/bin · high confidence
Add type stubs for torch.distributions with shape-aware typing
This change introduces comprehensive type stubs for the torch.distributions module, enabling static type checkers to understand tensor shapes in probability distributions. The stubs define a base Distribution class and specific distributions (like Normal, Categorical, Beta) that track event shapes using IntTuple and IntVar types. It also adds type definitions for constraints (e.g., \_GreaterThan, \_Interval) and transforms (e.g., AffineTransform, StickBreakingTransform), ensuring that operations like sample(), log\_prob(), and transform applications preserve or correctly compute output tensor shapes. Submodules like transforms and constraints are re-exported to maintain compatibility with existing import patterns.
tensor-shapes/pyrefly-torch-stubs/torch-stubs/distributions · high confidence
Add type stubs for torch.nn.attention module
Added type stubs for the \torch.nn.attention\ module, including the \flex\_attention\ sub-module. This provides static type checking support for flexible attention mechanisms, block-sparse masking via \BlockMask\, mask combinators (\and\_masks\, \or\_masks\), and kernel tuning options (\FlexKernelOptions\).
tensor-shapes/pyrefly-torch-stubs/torch-stubs/nn/attention · high confidence
Added benchmarking scripts for type checker performance
New scripts have been added to the \scripts/benchmark\ directory to measure and compare the execution time and memory usage of Python type checkers (pyright, pyrefly, ty, mypy, zuban) across popular open-source packages. The \typecheck\_benchmark.py\ script captures wall-clock latency and peak RSS memory, while \lsp\_benchmark.py\ measures LSP 'Go to Definition' latency. These tools allow users to generate detailed JSON reports and summary tables to evaluate type checker performance characteristics.
scripts/benchmark · high confidence
Added bundled pandas-stubs for type checking
The bundled third-party stubs now include type definitions for the pandas library. This adds comprehensive .pyi stub files covering the main pandas API, core data structures (DataFrame, Series, Index), configuration options, internal libraries, and testing utilities, along with the corresponding BSD 3-Clause license file. Users can now benefit from static type checking support for pandas within the bundled environment.
_crates/pyrefly\_bundled/third\party/stubs/pandas-stubs · high confidence
Added bundled type stubs for the Conan package manager
The bundled third-party stubs now include type definitions for the \conans\ library, enabling static type checking for Conan-related code. This addition covers the Conan API, CLI command structure, build system integrations (CMake, Meson, MSBuild, Autotools), and cache management components.
_crates/pyrefly\_bundled/third\party/stubs/conans-stubs · high confidence
Added conformance test documentation and update script
The conformance folder now includes a README.md explaining the structure of the Python typing conformance test suite and providing specific commands for GitHub and Meta internal developers to update test sources, check outputs, and compare results. Additionally, a new \update\_conformance\_sources.sh\ script was added to automate the process of cloning upstream Python typing tests and copying them into the \third\_party\ directory.
conformance · high confidence
Added pandas-stubs type hints for \_libs/tslibs and \_libs/window
This change adds bundled Python type stubs (.pyi files) for the pandas internal modules \_libs/tslibs and \_libs/window. Users will now receive type-checking support for core time-series components including Timestamp, Timedelta, Period, NaT, and various date offsets (e.g., BusinessDay, Hour, Day) when using pyrefly or compatible type checkers with pandas.
_crates/pyrefly\_bundled/third\_party/stubs/pandas-stubs/\_libs/tslibs, crates/pyrefly\_bundled/third\_party/stubs/pandas-stubs/\libs/window · high confidence
Added scikit-learn type stubs to Pyrefly bundle
Pyrefly now includes bundled type stubs for the scikit-learn library, enabling static type checking and improved IDE support for sklearn code. This addition covers core modules including clustering algorithms (KMeans, DBSCAN, AgglomerativeClustering, etc.), loss functions and distributions, base estimator mixins, and configuration contexts, along with the necessary MIT license file.
_crates/pyrefly\_bundled/third\party/stubs/sklearn-stubs · high confidence
Added type stubs for scikit-image
This change adds bundled type stubs for the scikit-image library, enabling static type checking and improved IDE support for code using scikit-image. The stubs cover core modules including feature detection (SIFT, ORB, HOG, Canny), image drawing, data fetching utilities, and graph-based segmentation, along with shared utilities and typing definitions.
_crates/pyrefly\_bundled/third\party/stubs/skimage-stubs · high confidence
Added type stubs for the SymPy library
The Pyrefly bundle now includes type stubs for the SymPy library, enabling type checking and autocomplete for SymPy code. This addition covers the main SymPy namespace along with submodules such as algebras (including Quaternion support), assumptions (with extensive predicate handlers for calculus, matrices, number theory, and sets), and core mathematical functions. A Microsoft MIT license file is also included to satisfy third-party attribution requirements.
_crates/pyrefly\_bundled/third\_party/stubs/sympy-stubs, crates/pyrefly\_bundled/third\party/stubs/vispy-stubs · high confidence
Bundled boto3 type stubs for static analysis
Pyrefly now includes bundled type stubs for the boto3 library, enabling static type checking for AWS SDK usage. This addition provides type annotations for the core boto3 session, resource models, and high-level interfaces for services such as DynamoDB (including condition expressions and type serialization) and S3 (including transfer configurations and file operations). A LICENSE file for the stubs is also included in the bundle.
_crates/pyrefly\_bundled/third\party/stubs/boto3-stubs · high confidence
Bundled typeshed now includes third-party stubs
The pyrefly\_bundled crate has been restructured to embed third-party type stubs alongside the standard library. The build script now creates separate compressed archives for stdlib and third-party stubs, allowing the binary to provide type information for external packages without requiring external files at runtime. This change ensures that import resolution can access both stdlib and third-party type definitions from the bundled binary.
_crates/pyrefly\bundled · high confidence
Enhanced module export analysis with deprecation, docstring, and nested symbol support
The export analysis engine now provides richer metadata for module symbols. Users will see deprecation warnings for symbols marked with the \@deprecated\ decorator, including the specific message provided in the decorator. Docstrings for module-level and exported symbols are now tracked and available for hover and completion features. Additionally, the system now builds a flat table of nested workspace symbols (such as methods and nested classes) for first-party modules, improving the accuracy of symbol navigation and search within complex codebases.
pyrefly/lib/export · high confidence
Initial JSON Schema definitions for Pyrefly configuration files
This change introduces JSON Schema definitions for Pyrefly's configuration files, providing validation, autocomplete, and documentation support for both standalone \pyrefly.toml\ and the \\[tool.pyrefly\]\ section in \pyproject.toml\. The schemas cover all current configuration options, including error severity settings, project includes/excludes, Python platform and version settings, import handling, baseline configuration, and build system settings. The schemas are designed to work with modern editors like VS Code (via the Even Better TOML extension) and PyCharm, and include test files and a validation script to ensure schema correctness.
schemas · high confidence
Initial public release of the Pyrefly website
The Pyrefly website (pyrefly.org) is now publicly available, providing comprehensive documentation, installation guides, and a WebAssembly-based interactive sandbox for testing type checking. The site includes introductory and technical blog posts detailing the tool's performance, IDE integration, and ecosystem contributions, such as improving NumPy's type completeness. It is built with Docusaurus and includes configuration for formatting, testing, and deployment.
website · high confidence
Initial release of the Pyrefly VS Code extension
This change introduces the Pyrefly VS Code extension, which replaces Pylance to provide Python language features such as inline type errors, go-to definition, and hover information. The extension uses the Pyrefly binary for analysis and includes configuration options like \typeCheckingMode\ to select type-checking presets, \disableTypeErrors\ to suppress diagnostics, and \disableLanguageServices\ to toggle specific LSP capabilities. It also adds a command to infer and write type annotations for the current file.
lsp · high confidence
Introduce CinderX type report with structured type table and human-readable display
Added a new CinderX type report system that walks the AST to collect per-expression inferred types, storing them in a deduplicated \TypeTable\ of structured entries (classes, callables, bound methods, variables, literals, and other forms) and mapping source locations to table indices. The report includes support for contextual types (e.g., for \\_\static\\_\ primitives) and facet narrowing mismatches, and provides a human-readable \.txt\ display alongside the JSON output for debugging.
pyrefly/lib/report/cinderx · high confidence
Introduce DataFrame schema support and typing.\_Alias resolution
Added explicit type modeling for DataFrame schemas (including Polars and Pandas) with column-level dtype tracking and completeness checks, enabling more precise type inference for data manipulation libraries. Additionally, added a new module to resolve \typing.\_Alias\ definitions (such as \List\, \Dict\, \Set\) to their concrete builtin equivalents (\list\, \dict\, \set\), improving accuracy for standard library type aliases.
_crates/pyrefly\types/src · high confidence
Introduce Glean report generation for Python code analysis
Added a new \convert.rs\ module in \pyrefly/lib/report/glean\ that transforms pyrefly's internal AST and type information into Glean schema facts. This enables users to generate structured reports containing cross-references (xrefs), definitions, imports, and file metadata, with support for resolving symlinks and normalizing paths for consistent cross-platform keys.
pyrefly/lib/report/glean · high confidence
Introduce JAX shape-aware type stubs for Pyrefly
This change adds the \jax-pyrefly-stubs\ package, a PEP 561 stub distribution that provides shape-aware type definitions for the JAX library. By installing this package, Pyrefly can discover and validate tensor shapes for JAX operations—including array creation, broadcasting, linear algebra, and neural network activations—without shadowing the runtime JAX installation. The stubs cover core modules like \jax.numpy\, \jax.lax\, \jax.nn\, and \jax.random\, enabling static type checking of tensor dimensions and shapes.
tensor-shapes/jax-pyrefly-stubs, tensor-shapes/jax-pyrefly-stubs/jax-stubs · high confidence
Introduce Pyrefly NumPy stubs package with shape-aware type checking and coverage tools
This change adds a new PEP 561 stub-only distribution (\pyrefly-numpy-stubs\) that provides NumPy type stubs with array shape information for Pyrefly, allowing static checks to discover shape-aware stubs without shadowing the runtime NumPy package. It includes a runner script (\run\_pyrefly.py\) to type-check NumPy shape-stub suites, a runtime test runner (\run\_runtime\_tests.py\) to execute suites against the real NumPy library, and a stub coverage inspection tool (\stub\_coverage.toml\) to verify coverage of specific NumPy members like \ndarray\. The package is configured to depend on \pyrefly-shape-extensions\ and uses a shared test harness to validate both type-checking errors and runtime behaviors.
tensor-shapes/pyrefly-numpy-stubs · high confidence
Introduce Pyrefly Torch stubs package with shape-aware type checking
This change adds a new PEP 561 stub-only distribution (\torch-stubs\) that provides PyTorch type stubs with tensor shape information for the Pyrefly static type checker. The package installs alongside the runtime \torch\ package without shadowing it, enabling users to perform static checks on their code using shape-aware annotations. The diff includes the package metadata, a configuration file (\pyrefly.toml\), and test runners (\run\_pyrefly.py\, \run\_runtime\_tests.py\) that allow users to validate their code against the new stubs. It also introduces a stub coverage inspection tool (\stub\_coverage.toml\) and opt-in support for \jaxtyping\ integration, allowing developers to verify that their PyTorch code adheres to the new shape constraints.
tensor-shapes/pyrefly-torch-stubs · high confidence
Introduce Pyrefly type stubs with precise shape inference for PyTorch
This change adds a new set of comprehensive type stubs for PyTorch (located in \torch-stubs/\) that enable precise shape inference for static type checkers. The stubs define type-level shape rules in \\shapes.pyi\ and apply them across the main \\\init\\_.pyi\, \fft.pyi\, \linalg.pyi\, and \return\_types.pyi\ modules. Users benefit from improved type-checking accuracy for tensor operations, including correct output shapes for FFT, linear algebra, and reduction functions, as well as proper handling of named return types and partial package resolution via \py.typed\. Also in this area: 6 commits (0 fixes) modifying tensor-shapes/pyrefly-torch-stubs/torch-stubs; Improved type inference for NumPy scalar constructors, ufuncs, and PyTorch tensor creation; Add type stubs for torch.compile and torch.half dtype alias; Improved shape inference for JAX activations and PyTorch affine\_grid/fold; Expanded type stubs for PyTorch distributions, linear algebra, and functional operations; and 1 more.
tensor-shapes/pyrefly-torch-stubs/torch-stubs · medium confidence · unverified
Introduce Type Server Protocol (TSP) crate with snapshot-aware type queries
The new \tsp\_types\ crate establishes the core type definitions and utilities for the Type Server Protocol. It introduces a \snapshotChanged\ notification mechanism, allowing clients to handle stale state, and defines request parameters for \getComputedType\, \getDeclaredType\, and \getExpectedType\ that include a snapshot version for consistency checks. The protocol supports querying types via either a simple \Node\ (URI and range) or a \Declaration\ (containing a nested node and extra metadata), enabling more precise type resolution for call expressions and other constructs.
_crates/tsp\types/src · high confidence
Introduce Type Server Protocol (TSP) v0.2.0 definition and generator
This change adds the Type Server Protocol (TSP) version 0.2.0 specification and the tooling to generate Rust bindings from it. The \tsp.json\ file defines the protocol's enumerations (such as \TypeFlags\ and \DeclarationCategory\), structures, and requests (including \typeServer/connection\, \typeServer/getComputedType\, \typeServer/getDeclaredType\, and \typeServer/getExpectedType\). The \generate\_protocol.py\ script uses the \lsprotocol\ generator infrastructure to convert these JSON definitions into a Rust \protocol.rs\ file, enabling the type server to communicate with clients using this new protocol.
_crates/tsp\_types/protocol\generator · high confidence
Introduce build-system-backed source database and module resolution
The \pyrefly\_build\ crate now provides a new source database layer that integrates with build systems (Buck2 and custom) to supply module information. This change introduces a \SourceDatabase\ trait and a \BuildSystem\ configuration structure, allowing the type checker to query build-system targets for module paths and handles. It also updates the module resolver to support PEP 561 partial stub packages and improves namespace package detection by caching \pkgutil\ checks, ensuring more accurate import resolution when build-system-provided data is available.
_crates/pyrefly\build/src · high confidence
Introduce bundled stubs for typeshed and third-party packages
The module finder now supports resolving type hints from stubs embedded directly in the binary via a new \BundledStub\ trait and \Bundle\ data structure. This enables the type checker to provide type information for the Python standard library and third-party packages (including \typeshed\ third-party stubs and other \-stubs\ packages) without requiring them to be installed on the user's system, while maintaining correct precedence over site-packages and handling \py.typed\ markers appropriately.
pyrefly/lib/module · high confidence
Introduce configuration presets and structured error severity management
Pyrefly now supports named configuration presets (Off, Basic, Legacy, Default, Strict, All) that allow users to select a base set of error severities and behavior settings, which can be further overridden by explicit configuration. This change introduces a structured \ErrorDisplayConfig\ system that manages error severities, supports deprecated alias lookups, and handles merging of user overrides against preset defaults. Additionally, the configuration system now includes dedicated modules for environment argument parsing, interpreter querying, and config file discovery, providing a more robust foundation for managing type-checking behavior across different project setups.
_crates/pyrefly\config/src · high confidence
Introduce isolated Glean schema crate for Python indexer reporting
A new \pyrefly\_glean\_schema\ crate has been added to isolate the Glean schema definitions from core builds. This crate provides the Rust types and serialization logic for emitting Glean JSON fact files containing Python indexer data, including schema entries, predicates, and ownership units. It exposes a structured API for generating reports that track Python code analysis results, such as cross-references, variable declarations, and file metadata, enabling downstream systems to consume standardized telemetry from the Python indexer.
_crates/pyrefly\_glean\schema · high confidence
Introduce literal-preserving Flag type parameters for shape extensions
Pyrefly now supports \Flag\ type parameters that preserve the literal value of their designated value parameter (e.g., \Literal\[True\]\ instead of just \bool\). This allows shape stubs to pass preserved literals to type-level DSL functions, avoiding the need for separate overloads for every option value. The implementation includes a new \FlagDomain\ representation with explicit members (Int, Bool, Str, IntTuple, NoneType) and an \Index\ restriction, integrated into the type variable restriction system.
_crates/pyrefly\_types/src/type\var · high confidence
Introduce new pyrefly subcommands and restructure the command-line interface
The command-line interface has been reorganized to expose new capabilities and improve usability. A new \pyrefly coverage\ command group has been added, splitting the previous \pyrefly report\ functionality into \pyrefly coverage report\ (with \pyrefly report\ now deprecated) and a new \pyrefly coverage check\ command to enforce minimum type-coverage thresholds. The \pyrefly init\ command now supports a \--dry-run\ flag for safe previews and a \--print-config\ flag to output the generated configuration to stdout. Additionally, dedicated commands for build-system integration (\pyrefly buck-check\ and \pyrefly bazel-check\) and a new \pyrefly snippet\ command for checking Python code snippets have been added to the main command enum.
pyrefly/lib/commands · high confidence
Introduce pyrefly-shape-extensions for library-agnostic static shape typing
The \pyrefly-shape-extensions\ package is now available, providing a set of runtime-safe type primitives for static shape analysis. It introduces \Int\ for symbolic dimension values, \IntTuple\ and \IntTuples\ for tuple-valued shapes, and \Elements\ to explicitly handle splatting of shape type variables. The library includes \Shaped\ (an alias for \Annotated\) to carry shape metadata as strings, and \shape\_vars\ to declare shape variables. It also features automatic runtime patching for PyTorch and JAX types to ensure they are subscriptable, and exposes DSL functions like \broadcast\ and \gufunc\_broadcast\ for shape evaluation.
pyrefly-shape-extensions · high confidence
Introduce pyrefly\_python crate with Python-specific utilities
A new \pyrefly\_python\ crate has been created to house Python-specific logic previously scattered across the codebase. This includes AST parsing helpers, comment section and folding range detection, docstring cleaning, dunder method definitions, ignore comment parsing, keyword handling, and module management. This change consolidates Python-specific functionality into a dedicated module.
_crates/pyrefly\python · high confidence
Introduce shape-aware type solving with Int and IntTuple domains
The solver now supports shape-specific type variables, allowing it to reason about array dimensions and tuple shapes. This change adds dedicated handling for \Int\ (dimension) and \IntTuple\ (shape) types, including normalization of dimension expressions, preservation of gradual sizes, and canonicalization of shape tuples. It enables the type checker to validate shape constraints in generic code, such as ensuring that type variables bounded by \Int\ or \IntTuple\ are solved to valid dimension values, and supports structural shape matching for shaped arrays.
pyrefly/lib/solver · high confidence
Introduce the Type Server Protocol (TSP) with multi-connection support
This change introduces the Type Server Protocol (TSP), a new protocol layer that allows external clients to query type information (such as declared, computed, and expected types) and manage workspace snapshots independently of the main LSP connection. The implementation in \pyrefly/lib/tsp\ adds a \TspServer\ and \TspConnection\ architecture that supports multiple simultaneous connections via IPC, handles snapshot versioning to ensure consistency, and provides specific request handlers for type resolution and import resolution. It also includes a robust type conversion system that maps internal pyrefly types to TSP protocol types, ensuring correct encoding of standard library classes and handling edge cases like Jupyter notebook URIs.
pyrefly/lib/tsp · high confidence
Introduces type-level shape DSL and TorchScript compatibility layer
Adds a new internal DSL for defining shape types (dsl.py) with support for integer tuples, einsum/einops operations, and gufunc broadcasting, alongside a TorchScript compatibility module (torchscript.py) that strips shape annotations from source code at import time to enable scripting. This change also marks the package as typed via py.typed.
_tensor-shapes/pyrefly-shape-extensions/shape\extensions · high confidence
Migrate mypy and pyright configuration files to Pyrefly
Pyrefly now automatically detects and migrates existing configuration from mypy (mypy.ini or \[tool.mypy\] in pyproject.toml) and pyright (pyrightconfig.json or \[tool.pyright\] in pyproject.toml, including basedpyright) into its own config format. This covers migrating project includes/excludes, error codes, import handling, Python interpreter and version settings, and platform configurations, allowing users to transition their type-checking setup without manual reconfiguration.
_crates/pyrefly\config/src/migration · high confidence
Migrate mypy configuration files to Pyrefly
Users can now automatically convert existing mypy configuration files (both \mypy.ini\ and \pyproject.toml\) into Pyrefly's native configuration format. The migration tool parses mypy-specific settings such as project includes/excludes, search paths, Python platform/version, and error codes, translating them into the corresponding Pyrefly config options. It also handles mypy-specific features like the \$MYPY\_CONFIG\_FILE\_DIR\ variable expansion and converts mypy's regex-based exclude patterns into Pyrefly's glob-based patterns.
_crates/pyrefly\config/src/migration/mypy · high confidence
New LSP code actions and refactoring capabilities
The language server now exposes several new code actions and refactoring features. Users can convert modules to packages and vice versa via the 'Convert module to package' and 'Convert package to module' actions. A new 'Move symbol to new file' action allows moving selected code into a new file, with proper handling for existing target files. Additionally, the server now provides code lenses for running main functions and tests, enabling direct execution from the editor.
_pyrefly/lib/lsp/non\wasm · high confidence
New LSP quick fixes and refactorings
This update introduces a suite of new code actions for the LSP interface. Users can now add missing \@override\ decorators, assert that values are not \None\, and convert dictionary literals into TypedDicts, dataclasses, or Pydantic models. Refactoring capabilities include extracting code into variables, functions, fields, or new superclasses, as well as changing function signatures by removing or reordering parameters. Additional fixes allow converting star imports to explicit imports, replacing string literals with enum members, and narrowing types using \is not None\ checks.
_pyrefly/lib/state/lsp/quick\fixes · high confidence
New PyTorch and micro benchmarks for performance regression testing
The \pyrefly/benches\ directory now includes a comprehensive benchmark suite to monitor performance. It features real-world benchmarks over a pinned PyTorch checkout (15k+ files) measuring cold-start, error propagation, workspace symbols, full-check throughput, and indexed memory usage, alongside a separate target for memory reporting. Additionally, microbenchmarks using the Criterion harness have been added to measure specific type-checking behaviors such as enum resolution, exhaustiveness, and generic constructor solving, as well as a TSP benchmark to verify solve-reuse for unopened files. A helper script and pinned revision file manage the PyTorch source checkout for both internal (Buck) and OSS (Cargo) builds. Also in this area: 33 commits (3 fixes) modifying pyrefly; 1 commit (0 fixes) modifying pyrefly/benches.
pyrefly/benches · medium confidence · unverified
New PyTorch model examples with tensor shape type annotations
Added annotated example implementations for multiple PyTorch models—including APG, Background Matting, BERT, DCGAN, Deep Recommender, Demucs, DenseNet, DLRM, and DRQ—adapted from TorchBenchmark. These files demonstrate the pyrefly shape type system by explicitly tracking tensor dimensions (batch, channels, spatial size) through complex operations like convolutions, upsampling, dense connections, and feature interactions, providing concrete reference patterns for users.
tensor-shapes/pyrefly-torch-stubs/examples · high confidence
New TSP type and import resolution requests
The TSP server now exposes several new requests to support richer type information and import resolution: \typeServer/getComputedType\ returns the inferred type at a position (accounting for control-flow narrowing), \typeServer/getDeclaredType\ returns the explicit annotation, and \typeServer/getExpectedType\ returns the contextually expected type (falling back to computed type when no context applies). Additionally, \typeServer/resolveImport\ resolves absolute and relative Python imports to their file URIs, \typeServer/getPythonSearchPaths\ returns the directories used for import resolution (including notebook-aware path resolution), \getSnapshot\ exposes the current state epoch, and \getSupportedProtocolVersion\ reports the supported TSP protocol version.
pyrefly/lib/tsp/requests · high confidence
New WASM-specific LSP implementation for completions, hover, and inlay hints
This change introduces a new set of Rust modules in \pyrefly/lib/lsp/wasm\ that implement the LSP protocol features required for the WASM build. The new \completion.rs\ module provides completion ranking logic, auto-import support, and keyword handling. The \hover.rs\ module adds hover functionality, including Sphinx cross-reference resolution and type source display. The \inlay\_hints.rs\ module implements type annotation inlay hints with automatic import insertion. Additionally, \notebook.rs\ adds support for Jupyter notebook document synchronization, \provide\_type.rs\ implements an experimental custom LSP method for type resolution, \semantic\_tokens.rs\ handles semantic token generation, \signature\_help.rs\ provides function signature assistance, and \type\_source.rs\ tracks and displays the origin of inferred types.
pyrefly/lib/lsp/wasm · high confidence
New \`pyrefly coverage check\` command with strict mode and threshold enforcement
The \pyrefly coverage\ command now includes a \check\ subcommand that gates type-annotation coverage against a configurable threshold. Users can set a minimum coverage percentage via \--fail-under\ (defaulting to 100%) to fail the command if coverage drops below that level. A new \--strict\ flag allows users to treat \Any\-resolved annotations as untyped, providing a stricter measure of coverage. The command also supports \--public-only\ to restrict checks to symbols reachable from public modules and \--output-format\ to control how untyped-symbol findings are displayed.
pyrefly/lib/commands/coverage · high confidence
New diagnostic and analysis report formats
The report module now includes several new output formats for debugging and integration: a binding memory report that tracks the count and size of bindings per module, a dependency graph report mapping module paths to their dependencies, a CinderX report providing structured type data and class metadata for the CinderX compiler, a Glean report for telemetry, a PySA report for security analysis, and a trace report showing types and definitions for expressions. Additionally, the debug info output has been refactored to use the Answers system and is formatted to be more easily diffable.
pyrefly/lib/report · high confidence
New experimental programmatic type-checking API for embedders
An experimental, non-stable API is now available in the \pyrefly\ library to allow embedders (such as sandboxed interpreters or REPLs) to perform type checking programmatically. The new \Checker\ struct provides a reusable, warm state that amortizes the typeshed load, enabling efficient 'source in, diagnostics out' checks against in-memory modules without requiring the full editor-oriented playground. This interface is intended for internal or experimental use and may change without notice during minor version increments.
pyrefly/lib · high confidence
New pyrefly\_graph crate for thread-safe graph calculations
The \pyrefly\_graph\ crate has been introduced to handle graph-based calculations with a focus on thread safety and performance. It provides a \Calculation\ type that allows multiple threads to compute values in parallel (e.g., for mutually recursive dependencies) without deadlocking, using atomic status tracking and write-locking for result publication. The crate also includes an \Index\ and \IndexMap\ for efficient, type-safe key management within the graph structure.
_crates/pyrefly\graph · high confidence
New scope-aware AST visitor and call graph infrastructure for Pysa reports
The Pysa reporting module now includes a new scope-aware AST visitor (\ast\_visitor.rs\) and a comprehensive call graph builder (\call\_graph.rs\) that parse Python source to extract function definitions, class structures, captured variables, and global variables. This infrastructure introduces detailed scope tracking (distinguishing exported vs. non-exported functions/classes, decorators, and type parameters) and builds a rich call graph with specific origin kinds for various Python constructs (e.g., augmented assignments, subscript operations, for-loop iterations, and decorator targets). The changes also add support for serializing class definitions, function signatures, and captured variable information into the Pysa report format, enabling more precise taint analysis by understanding the full context of function calls and variable usage within modules.
pyrefly/lib/report/pysa · high confidence
New skill for porting PyTorch models to pyrefly tensor shape types
A new skill, \add-shape-types-to-torch-model\, has been added to guide the porting of PyTorch models to use pyrefly's tensor shape type system (e.g., \Tensor\[\[B, C, H, W\]\]\). This skill provides a gated workflow for annotating model forward methods, preserving jaxtyping precision, and handling shape tracking via stubs, DSL functions, and special handlers. It includes documentation on porting principles, shape tracking capabilities, and a style guide, along with a verification script (\verify\_port.sh\) to audit ports for issues like bare \Tensor\ annotations and missing \assert\_type\ checkpoints.
tensor-shapes/skills · high confidence
New stubgen module for generating .pyi stub files
The \pyrefly/lib/stubgen\ directory now contains the core logic for generating Python stub files. The \extract.rs\ module walks the module's AST and uses solved type answers to build a structured \ModuleStub\ representation, while \emit.rs\ renders this structure into valid \.pyi\ text, handling imports, classes, functions, variables, and type aliases.
pyrefly/lib/stubgen · high confidence
New test harness and stub coverage inspection tool for tensor-shapes
The tensor-shapes area now includes a unified test runner (\run\_all\_shape\_tests.py\ and \run\_tests.py\) that executes both static type-checking and runtime shape tests for PyTorch, NumPy, JAX, and einops stubs, alongside a new \stub\_coverage.py\ tool that inspects and reports gaps between the shipped \.pyi\ stubs and the actual runtime libraries. These changes are supported by a bootstrapping script (\bootstrap\_venv.py\) that creates a shared Python 3.13 virtualenv with pinned dependencies (NumPy 2.5.0, JAX 0.11.2, PyTorch 2.12.1+cpu) and a suite of unit tests (\test\_run\_tests.py\, \test\_stub\_coverage.py\) validating the new infrastructure.
tensor-shapes · high confidence
New utility library for path resolution, file watching, and globbing
The \pyrefly\util\ crate now provides a suite of shared utilities for the Pyrefly toolchain. This includes an \Absolutize\ trait for robust path resolution and relative path computation, a \CategorizedEvents\ struct to filter and categorize file watcher events (excluding \\\pycache\\_\ and stdlib files), and a \Glob\ implementation that supports \.py\, \.pyi\, \.pyw\, and \.ipynb\ files while respecting \.gitignore\ and \.ignore\ rules. Additional helpers include \ArcId\ for pointer-based identity, \InternedPath\ for efficient path storage, and \LinedBuffer\ for handling source positions and notebook cell mappings.
_crates/pyrefly\util · high confidence
Pyrefly 1.4.0-dev.2 release with new developer tooling and documentation
This release updates the version to 1.4.0-dev.2 and introduces several new files to support the development workflow and project structure. It adds \AGENTS.md\ with comprehensive guidance for AI coding agents, \REVIEW.md\ for code review instructions, and \ARCHITECTURE.md\ detailing the type checker's design. Developer tooling is enhanced with \ruff.toml\ for Python formatting, \rustfmt.toml\ for Rust formatting, and \rust-toolchain.toml\ specifying the stable Rust toolchain with clippy and rustfmt components. The repository also includes a new GitHub Action (\action.yml\) for type checking, a \debug.html\ interface for debugging bindings, and updated \README.md\ and \CONTRIBUTING.md\ files reflecting the new project status and contribution guidelines.
(repo-wide) · high confidence
Pyrefly VS Code extension introduces new interactive features and improved environment handling
The extension now provides runnable code lenses for executing tests and main functions directly from the editor, supports docstring folding via a dedicated command, and offers hover tooltips with +/- controls to adjust verbosity levels. It also integrates with the Python extension ecosystem by preferring the vscode-python-environments API when available, automatically disabling conflicting language servers like Pyright, and displaying build system status in the status bar.
lsp/src · high confidence
Pyrefly WASM sandbox exposes full language service API
The pyrefly\_wasm crate now provides a comprehensive JavaScript API for the browser-based sandbox, enabling features like multi-file editing, hover information, semantic tokens, go-to-definition, autocomplete, and inlay hints. The WASM module exports a State object with methods such as updateSandboxFiles, hover, semanticTokens, gotoDefinition, autoComplete, and inlayHint, allowing the frontend to interact with the Pyrefly type checker and language server capabilities directly in the browser.
_pyrefly\wasm · high confidence
Runtime examples for GPT model with symbolic shape annotations
The runtime examples directory now includes runnable and type-annotated variants of a NanoGPT model (nanogpt\_future\_annotations.py, nanogpt\_sym\_int\_var.py, and their runnable counterparts). These files demonstrate how to use the shape\_extensions library to express tensor dimensions symbolically using Int, IntVar, and IntTuple types, enabling generic PyTorch modules (LayerNorm, CausalSelfAttention, MLP, Block) to carry shape constraints at runtime. The examples show both PEP 695-style generic syntax and traditional TypeVar-based Generic patterns, with runnable variants stripping assert\_type calls for safe execution.
tensor-shapes/pyrefly-torch-stubs/examples/runtime · high confidence
Shape-aware type stubs for NumPy linear algebra functions
Added type stubs for the \numpy.linalg\ module that model tensor shapes using the new \Int\ and \IntVar\ DSL. This provides shape inference for functions like \solve\, \norm\, \eigh\, and \svd\ (restricted to reduced SVD), while preserving standard re-exports from the underlying NumPy implementation.
tensor-shapes/pyrefly-numpy-stubs/numpy-stubs/linalg · high confidence
Shape-aware type stubs for einops operations and PyTorch layers
This release adds a PEP 561 stub distribution for the \einops\ library, providing shape-aware type annotations for the \rearrange\, \reduce\, \repeat\, and \einsum\ functions, as well as the \Rearrange\ and \Reduce\ layers in \einops.layers.torch\. The stubs use Pyrefly's type-level shape DSL to track axis lengths and patterns, allowing static type checkers to verify tensor shapes at compile time. The implementation currently targets PyTorch tensors, preserving constructor patterns and axis lengths across calls, while also including runtime tests that validate the shared einops pattern semantics against NumPy and JAX backends. Also in this area: 3 commits (1 fix) modifying tensor-shapes; 3 commits (0 fixes) modifying tensor-shapes/pyrefly-einops-stubs.
tensor-shapes/pyrefly-einops-stubs, tensor-shapes/pyrefly-einops-stubs/einops-stubs, tensor-shapes/pyrefly-einops-stubs/test · medium confidence · unverified
Support for Buck2 and custom source DB queriers
Users can now query source databases using Buck2 or arbitrary custom commands. The new Buck2 querier supports resource isolation via systemd cgroups in fbcode environments and passes build IDs to the query process. Additionally, a custom querier allows users to define their own command-line tools for source DB queries, with support for shared repository roots.
_crates/pyrefly\build/src/query · high confidence
Support running pyrefly as a Python module
Users can now invoke pyrefly using \python -m pyrefly\ (and \py -m pyrefly\ on Windows). This change adds a \\_\main\\.py\ entry point that locates the installed pyrefly executable and runs it, while also exposing a \\\version\\_\ attribute in the package for programmatic access to the version number.
pyrefly/python · high confidence
Architecture
Extracted reusable LSP test harness into a separate crate
The in-process LSP test infrastructure has been extracted from the main \pyrefly\ crate into a new, standalone \pyrefly\_lsp\_test\ crate. This change allows both the \lsp\_interaction\ tests and the \pyrefly\ benchmarks to share a common \TestClient\ harness that spawns the language server on a thread and communicates via in-memory channels, while also resolving potential type mismatches by re-exporting specific LSP types from the main crate.
_crates/pyrefly\_lsp\test · high confidence
Refactor class field and metadata logic to use TypeHeap and new binding structures
The class field and metadata calculation logic in \pyrefly/lib/alt/class\ has been refactored to migrate type construction to use \TypeHeap\ factory methods (e.g., \TypeHeap::mk\_type\) and to adopt new binding structures like \Binding::None\ and \Binding::Any\. This change replaces direct \ClassType\ construction and legacy \Class\ fields with a more structured approach using \ClassFieldInner\ variants (such as \Method\, \Property\, \Descriptor\, and \NestedClass\) and \ClassBases\ for base class metadata. The refactoring also involves moving variance inference and metadata calculations (for dataclasses, pydantic, django, and typed dicts) into dedicated helper functions and solver scopes, improving code organization and reducing memory allocations by avoiding unnecessary clones and using \SmallMap\ structures.
pyrefly/lib/alt/class · high confidence
Behavioural changes
1 commit (0 fixes) modifying pyrefly/lib/report/scip
A change to existing behaviour in pyrefly/lib/report/scip — 1 commit, 107 files: “SCIP indexer (\#5504)” (refs \#5504).
pyrefly/lib/report/scip · medium confidence · unverified
3 commits (1 fix) modifying tensor-shapes/microtorch/examples
A change to existing behaviour in tensor-shapes/microtorch/examples — 3 commits (1 fix), 8 files: “Fix the microtorch sandbox examples”; “Align the overview example with its sandbox”; “Move sandbox examples into microtorch”.
tensor-shapes/microtorch/examples · medium confidence · unverified
4 commits (0 fixes) modifying .agents/skills/score-pyrefly-change
A change to existing behaviour in .agents/skills/score-pyrefly-change — 4 commits, 4 files: “Improve the interpret-mypy-primer skill”; “Add interpret-mypy-primer skill for analyzing error differentials”; “Add score-pyrefly-change skill”; and 1 more.
.agents/skills/score-pyrefly-change · medium confidence · unverified
4 commits (0 fixes) modifying pyrefly/benches/tsp
A change to existing behaviour in pyrefly/benches/tsp — 4 commits, 10 files: “Move the TSP benchmark into benches/tsp/”; “Record the TSP requests Pylance sends on a slow PyTorch file”; “Benchmark TSP against LSP for a cold start on PyTorch (\#5438)”; and 1 more (refs \#5438).
pyrefly/benches/tsp · medium confidence · unverified
4 commits (0 fixes) modifying tensor-shapes/jax-pyrefly-stubs
A change to existing behaviour in tensor-shapes/jax-pyrefly-stubs — 4 commits, 6 files: “jax.numpy.reshape: support -1 dimensions (\#5618)”; “add missing primitive declarations in jax.lax (\#5620)”; “Add tuple overloads for jax.lax.associative\_scan/reduce and split fori\_loop body\_fun (\#5607)”; and 1 more (refs \#5618, \#5620, \#5607, \#5616). Also in this area: Add JAX LAX stubs with shape inference and polynomial support.
tensor-shapes/jax-pyrefly-stubs/jax-stubs/lax · medium confidence · unverified
54 commits (14 fixes) modifying pyrefly/lib/state/lsp
A change to existing behaviour in pyrefly/lib/state/lsp — 54 commits (14 fixs), 5 files: “complete known dict keys in a half-typed subscript”; “Prefer module-local named fixtures over conftest”; “Fix duplicate completions when typing TypedDict key in .get() (\#2482)”; and 51 more (refs \#2482, \#1442, \#3023, \#2207, \#2692, …).
pyrefly/lib/state/lsp · medium confidence · unverified
6 commits (0 fixes) modifying pyrefly/lib/commands/check
A change to existing behaviour in pyrefly/lib/commands/check — 6 commits, 1 file: “Write reports in parallel, without passing them through anstream”; “feat(typechecking): SARIF output for \pyrefly check\ (\#4208)”; “migrate from lsp-types fork to gen-lsp-types 0.11.0 (\#5032)”; and 3 more (refs \#4208, \#5032, \#4551).
pyrefly/lib/commands/check · medium confidence · unverified
62 commits (5 fixes) modifying scripts
A change to existing behaviour in scripts — 62 commits (5 fixs), 13 files: “Warn on individual signatures that rely on unresolved imports”; “Open source comparison script to be able to run on github actions”; “Show reveal\_type output under the basic preset' (\#5573)”; and 58 more (refs \#5573, \#5083, \#5171, \#3464, \#4669, …).
scripts · medium confidence · unverified
Expanded shape-comment corpus with NumPy demos and compact syntax updates
The comment-shape corpus now includes a new NumPy demo alongside the existing SciPy demo, providing type-checking fixtures for \outer\, \tensordot\, \roll\, \diag\, \tril\, \triu\, \expand\_dims\, \tile\, and \kron\. The shape-comment syntax has been updated to use bracket selectors (e.g., \\[0\]\) instead of dot notation (e.g., \.0\) for selecting type arguments, and the \type =\ keyword is now optional in favor of the shorter \= payload\ form. Additionally, the SciPy examples have been refactored to use per-component shape comments, allowing shape relationships to be specified directly beside tuple carriers rather than using long nested selectors.
tensor-shapes/comment-shape-corpus · high confidence
Improved Pyrefly binary discovery within the selected Python environment
The LSP resources now include a dedicated script to locate the \pyrefly\ binary that is installed in the user's currently selected Python environment. This script prioritizes binaries found within the active virtual environment over those installed globally or in other locations, ensuring that the language server uses the correct version of Pyrefly associated with the project's environment. Tests verify that the discovery logic correctly ignores binaries outside the selected environment and handles cases where Pyrefly is not installed.
lsp/resources · high confidence
Introduce structured type-table API with structural hashing
The \type\_table\ query now returns a new structured format (\TypeTableResponseData\) containing deduplicated type shapes (\IndexedTypeShapeKind\) alongside a location-to-index mapping (\types\). Each shape entry includes a stable structural hash, enabling clients to cache parsed types across files and requests. The API supports serializing named types, callables (including staticmethod flags), and type variables, while dropping the previous per-location display strings in favor of this compact, hash-based representation.
pyrefly/lib/query · high confidence
Major overhaul of error reporting, baseline matching, and suppression logic
The error handling subsystem has been significantly refactored to improve diagnostic clarity and baseline management. Error messages now include structured details, secondary annotations for richer context (such as operand types in binary operations), and support for quick fixes. Baseline matching has been enhanced with configurable modes (column-ordered and concise-description) and the ability to record severity thresholds, ensuring stable comparisons across runs. Suppression logic has been refined to better handle f-strings, inline ignores, and the removal of unused suppressions, while output formats now include severity levels and support for CodeClimate integration.
pyrefly/lib/error · high confidence
Proc-macro derive macros now support lifetime parameters
The \TypeEq\, \Visit\, and \VisitMut\ derive macros in the \pyrefly\_derive\ crate have been updated to handle generic lifetime parameters on structs and enums. Previously, these macros likely failed or produced incorrect code when applied to types with lifetimes; now they correctly propagate lifetimes in the generated trait implementations, allowing users to derive these traits on lifetime-generic types without manual implementation.
_crates/pyrefly\derive · high confidence
Pyrefly Torch stubs examples adopt Int/IntVar naming and support runtime-safe type variables
The pyrefly-torch-stubs examples (including GPT-2, Mixtral MoE, and their runtime variants) have been updated to use the renamed \Int\, \IntVar\, and \IntTuple\ types from \shape\_extensions\ instead of the previous \Size\/\SymVar\/\SizeTuple\ naming. This change aligns the stubs with the underlying type system where \SymVar\ (now \IntVar\) is the specific kind that supports arithmetic operations, distinguishing it from standard \TypeVar\. The examples now demonstrate both PEP 695 generic syntax and legacy \Generic\/\TypeVar\ patterns, with runnable variants stripping \assert\_type\ calls for runtime safety, ensuring type checkers can correctly infer tensor shapes for operations like reshape, view, and attention.
pyrefly-torch-stubs · high confidence
Pyrefly type-checker engine overhaul and feature expansion
The pyrefly type-checker engine has undergone a massive overhaul, introducing support for complex data science schemas (Polars DataFrame and Series type inference, JAX/JAXtyping integration, and PyTorch tensor shape tracking), modern Python typing features (PEP 695/696/747 support, \Annotated\ types, \Self\ type resolution, and \TypeForm\), and significant performance and stability improvements (iterative SCC solving to prevent stack overflows, \TypeHeap\ memory management, and exhaustive match statement checking). This update also adds new linting rules (deprecated calls, redundant casts, untyped parameters), improves error diagnostics, and refactors the core solver architecture.
pyrefly/lib/alt · high confidence
Refactor LSP module path resolution and platform-specific module exports
The LSP module handling has been restructured to improve how bundled type stubs (such as typeshed and third-party stubs) are resolved to real file paths and to separate platform-specific module exports. A new \module\_helpers.rs\ file introduces \to\_real\_path\ to convert internal \ModulePath\ details (including \BundledTypeshed\, \BundledTypeshedThirdParty\, and \BundledThirdParty\) into user-visible \PathBuf\ objects, falling back to None for WebAssembly builds where disk access is unavailable. It also provides \collect\_symbol\_def\_paths\ to gather definition locations for type symbols, ensuring bundled types are correctly mapped to their materialized disk paths. Additionally, the module structure is split into \non\_wasm.rs\ and \wasm.rs\ to conditionally export platform-specific modules (e.g., \server\, \workspace\ for non-WASM; \completion\, \hover\ for WASM), aligning the LSP server's public API with the target architecture.
pyrefly/lib/lsp · high confidence
Refactor module dirty tracking into lock-free atomic storage
The module state system now uses a new \AtomicComputedDirty\ structure to combine the computed epoch and dirty flags into a single \AtomicU64\. This change replaces separate atomic operations with a single compare-and-swap loop, ensuring that checking if data is stale and marking dependencies as dirty happens atomically. This eliminates race conditions in incremental dirty tracking and reduces lock contention during concurrent rechecks, resulting in more reliable and faster IDE responses when files change.
pyrefly/lib/state · high confidence
Refactored Python interpreter discovery and environment configuration
The Python environment configuration module has been restructured to improve interpreter discovery and environment handling. Interpreter querying is now isolated in its own module, caching stdlib paths for performance. The system now distinguishes between active environments (detected via VIRTUAL\_ENV or CONDA\_PREFIX) and project-level virtual environments, with optimized discovery for venvs in directory trees. Conda environment detection is restricted to the \<env\_name\>/bin directory. A new configurable \python-interpreter-find-command\ allows custom interpreter discovery scripts. The configuration schema now uses kebab-case field names (e.g., \python-interpreter-path\, \python-interpreter-find-command\) with backward compatibility aliases. Interpreter selection priority has been adjusted to give LSP/IDE-provided interpreters higher precedence than auto-discovered ones, while still respecting explicit CLI overrides.
_crates/pyrefly\config/src/environment · high confidence
Refactored source database architecture with new query and manifest handling
The source database implementation has been restructured to improve modularity and performance. A new \QuerySourceDatabase\ now manages target manifests, path lookups, and file watching patterns, replacing the previous monolithic approach. This change introduces a \SourceDbQuerier\ trait to decouple the query logic from the database state, allowing for more flexible integration with build systems like Buck. Additionally, a new \BuckCheckSourceDatabase\ handles manifest-based lookups for buck-check operations, filtering out Pyre typeshed stubs to prevent spurious errors. The \MapDatabase\ has been updated to use \Vec1\ for module paths, ensuring at least one path is always present, and the system now supports config overrides and default configurations supplied by the build system.
_crates/pyrefly\_build/src/source\db · high confidence
Refactored type system internals for class and function metadata
The type-checking engine in \pyrefly/lib/alt/types\ has been restructured to improve how class and function metadata is stored and accessed. A new \ClassBases\ struct now explicitly tracks direct base types, source ranges, and the first tuple ancestor, separating this data from general class metadata to prevent cyclic dependencies during type argument calculation. \ClassMetadata\ has been expanded to include detailed tracking for Pydantic models (including strict mode and validation flags), Django models and serializers, dataclass transforms, and disjoint-base status. Function handling has been split into \UndecoratedFunction\ (pre-decorator state) and \Decorator\ (post-decorator state), allowing for more precise analysis of special decorators like \@cached\_property\ and \@disjoint\_base\. Additionally, a new \Instance\ wrapper unifies class and TypedDict instances, and \YieldResult\ types have been migrated to use the new \TypeHeap\ factory methods.
pyrefly/lib/alt/types · high confidence
Support for bundled third-party type stubs
The pyrefly\_bundled crate now includes support for third-party type stubs alongside the standard library. Users benefit from improved resolution of third-party stub paths and more accurate package name recommendations, as the new code correctly handles the directory structure of typeshed's stubs (e.g., mapping \typeshed/stubs/package-name/...\ to the correct package context) and respects the \VERSIONS\ file for stdlib modules. This change also fixes bugs related to multiple versions of materialized bundled typeshed and ensures that third-party stubs are properly integrated into the bundled archive.
_crates/pyrefly\bundled/src · high confidence
Updated JAX NumPy stubs for v0.12.0 with improved shape inference and sharding support
The JAX NumPy stubs have been updated to align with JAX v0.12.0, introducing several improvements to static analysis and type checking. Shape inference for \tensordot\ now supports nested axes, and the \matmul\ stubs accept additional keyword options. Furthermore, missing \out\_sharding\ parameters have been added to various \jax.numpy\ APIs, and the stubs now include comprehensive type definitions for the \fft\ and \linalg\ submodules, enhancing accuracy for array shape and sharding predictions.
tensor-shapes/jax-pyrefly-stubs/jax-stubs/numpy · high confidence
Updated bundled typeshed stubs
The bundled typeshed stubs in the standard library have been updated to a newer version. This brings improved type checking coverage and accuracy for Python standard library modules, including updated signatures for modules like asyncio, csv, and codecs, as well as support for newer Python versions (up to 3.15 in some stubs).
_crates/pyrefly\_bundled/third\party/typeshed · high confidence
Updated conformance test suite with new typing specification tests
The conformance test suite has been updated with new test cases covering recent typing specifications. This includes tests for \typing.ClassVar\ usage and restrictions, comprehensive dataclass behavior (including \frozen\, \slots\, \kw\_only\, \match\args\, inheritance, and \\\_post\init\\_\), \typing.Self\ with attributes, \infer\_variance\ for TypeVars, \typing.disjoint\_base\ (PEP 800), and \typing.Annotated\/\Final\ qualifiers. Additionally, the \conformance\_output.py\ script was modernized to support Windows and improved logging.
python · high confidence
Fixes
Restored missing torch.nn submodules and re-exports in type stubs
The type stubs for the \torch.nn\ package have been updated to restore previously missing submodules and re-exports. The \\_\init\\_.pyi\ file now explicitly imports and re-exports submodules such as \attention\, \functional\, \init\, \modules\, and others, ensuring they resolve correctly as attributes. Additionally, the \init.pyi\ stubs now provide shape-aware signatures for weight initialization functions (e.g., \kaiming\uniform\\, \xavier\normal\\), and the \parameter.pyi\ stub restores the \Buffer\ and \Parameter\ re-exports. This change ensures that static type checkers can correctly resolve all standard \torch.nn\ components and their initialization utilities.
tensor-shapes/pyrefly-torch-stubs/torch-stubs/nn · high confidence
Test coverage
1 commit adding/updating tests in pyrefly/lib/test/lsp/lsp\_interaction/test\_files/baseline\_error\_cap, pyrefly/lib/test/lsp/lsp\_interaction/test\_files/baseline\_warn; 2 commits adding/updating tests in tensor-shapes/pyrefly-torch-stubs; 3 commits adding/updating tests in tensor-shapes/microtorch/test; Add conformance test support for @deprecated warnings and enum member value inference; Added LSP interaction tests for third-party stub behavior; Added Pydantic v2 stubs for type checking; Added compatibility tests for shape-annotated libraries across multiple type checkers; Added comprehensive test coverage for Django type inference; Added comprehensive type-level shape tests for NumPy stubs; Added expect-style test fixtures for CinderX type inference; Added extension test suite for LSP path resolution and server recovery; Added integration tests for LSP startup settings and configuration race conditions; Added integration tests for TSP server interaction; Added negative tests for static jaxtyping shape checking; Added runtime tests for tensor shape annotations and TorchScript compatibility; Added shape-inference tests for JAX stubs; Added test cases for unused parameter detection; Added test coverage for .pyi preference when .py is missing; Added test coverage for CLI arguments, auto-configuration, and baseline management; Added test coverage for Polars schema and dtype inference; Added test coverage for Pydantic model configuration and validation behaviors; Added test coverage for attrs library integration; Added test coverage for functools.partial and functools.singledispatch; Added test coverage for jaxtyping static shape checking; Added test coverage for nested package imports with aliased submodules; Added test coverage for pyrefly coverage report edge cases; Added test coverage for untyped import recommendations; Added test coverage for unused type-ignore baselines; Added test files for unused import detection; Added test fixtures for LSP baseline hint behavior; Added test fixtures for auto-importing submodules; Added test fixtures for cross-file invalidation in project mode; Added test fixtures for deep submodule chains and external package access; Added test fixtures for module package conversion; Added test fixtures for multi-byte UTF-8 workspace symbols; Added test fixtures for relative import module resolution; Added test fixtures for relative import scenarios; Added test fixtures for safe delete file functionality; Added test fixtures for safe file deletion scenarios; Added test fixtures for workspace diagnostics configuration scenarios; Added test fixtures for workspace symbol preference of non-init modules; Added test for relative imports outside configured search paths; Added test infrastructure and type stubs for factory\_boy; Added test suite for TSP request handlers; Added tests for LSP baseline auto-update behavior; Added tests for Pyrefly extension activation failure and recovery; Added tests for TSP protocol type serialization and construction; Added tests for moving symbols to new files; Added tests for non-Jupyter notebook support and exclusion rules; Added tests for pandas DataFrame type inference and stub correctness; Added tests for project-includes and project-excludes filtering; Added tests for shape extension runtime behavior; Added tests for untyped third-party stub handling; Added tests for version helper utilities; Added tests for workspace with no folders; Added type stubs for the attrs library; Added unit tests for Pyrefly call graph and Pysa export logic; Expanded LSP interaction test coverage; Expanded LSP test coverage for core IDE features; Expanded LSP test coverage for inlay hints, diagnostics, and error suppression; Expanded Pyrefly test coverage for PyTorch tensor shapes; Expanded stubgen snapshot test coverage; Expanded test coverage for type checking engine; Snapshot tests for type-checking laziness and demand trees.
Dependencies
Initial project scaffolding and dependency configuration
This change introduces the foundational build configuration for the Pyrefly project. It establishes a Rust workspace with 14 crates (including \pyrefly\, \pyrefly\_config\, \pyrefly\_lsp\_test\, and \tsp\_types\) and sets the Rust edition to 2024. It also adds the initial \Cargo.lock\, \package-lock.json\, and \pyproject.toml\ files, along with the \website/package.json\ for the Docusaurus-based documentation site. The configuration pins specific versions for core dependencies such as \serde\, \tokio\, \clap\, and \lsp\_types\ (via the \gen-lsp-types\ fork), and configures release profiles with LTO and debug info stripping.
(dependencies) · high confidence
Housekeeping
Configured flake8 to ignore rules conflicting with Black
Added a .flake8 configuration file to the primer\_classifier script directory to suppress linting errors E203 (whitespace before ':'), W503 (line break before binary operator), and E501 (line too long), ensuring compatibility with the Black code formatter.
_scripts/primer\classifier · high confidence
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 64 → 62 (-2.0)
- Rubric changed (rubric-2026.10.5 → rubric-2026.11.4) — scores are not directly comparable.
Lenses
- Code Health 59 → 55 (-4.1)
- Architecture 95 → 95 (+0.2)
- Maturity 66 → 66 (-0.0)
- Readiness 73 → 73 (-0.5)
- Security 61 → 64 (+3.2)
- Event Sourcing 100 → 100 (+0.0)
- Performance 94 → 73 (-21.4)
Resolved (270)
- AnswersSolver::atomic_narrow_for_facet (cognitive 20) (pyrefly/lib/alt/narrow.rs)
- AnswersSolver::atomic_narrow_for_facet (cyclomatic 18) (pyrefly/lib/alt/narrow.rs)
- AnswersSolver::calculate_and_record_answer (cognitive 16) (pyrefly/lib/alt/answers_solver.rs)
- AnswersSolver::check_sqlalchemy_update_values_call (cognitive 17) (pyrefly/lib/alt/expr.rs)
- AnswersSolver::expr_infer_without_shape_comment (cognitive 18) (pyrefly/lib/alt/expr.rs)
- AnswersSolver::infer_shaped_array_index (cognitive 50) (pyrefly/lib/alt/expr.rs)
- AnswersSolver::infer_shaped_array_index (cyclomatic 32) (pyrefly/lib/alt/expr.rs)
- AnswersSolver::inject_module_attrs (cognitive 25) (pyrefly/lib/alt/callable.rs)
- AnswersSolver::paramspec_from_call (cognitive 18) (pyrefly/lib/alt/expr.rs)
- AnswersSolver::parse_registered_shaped_array_type (cognitive 49) (pyrefly/lib/alt/expr.rs)
- AnswersSolver::parse_registered_shaped_array_type (cyclomatic 27) (pyrefly/lib/alt/expr.rs)
- AnswersSolver::parse_type_shape_dsl_argument (cognitive 28) (pyrefly/lib/alt/type_level_dsl.rs)
- AnswersSolver::parse_type_shape_dsl_argument (cyclomatic 17) (pyrefly/lib/alt/type_level_dsl.rs)
- AnswersSolver::typevar_from_call (cognitive 34) (pyrefly/lib/alt/expr.rs)
- AnswersSolver::typevar_from_call (cyclomatic 24) (pyrefly/lib/alt/expr.rs)
- AnswersSolver::typevartuple_from_call (cognitive 19) (pyrefly/lib/alt/expr.rs)
- AnswersSolver::validate_type_var_default (cognitive 33) (pyrefly/lib/alt/solve.rs)
- AnswersSolver::validate_type_var_default (cyclomatic 25) (pyrefly/lib/alt/solve.rs)
- BindingsBuilder::extract_shaped_array_metadata (cognitive 43) (pyrefly/lib/binding/shape_type.rs)
- BindingsBuilder::extract_shaped_array_metadata (cyclomatic 18) (pyrefly/lib/binding/shape_type.rs)
- …and 250 more
New (501)
- AnswersSolver::analyze_class_field_value (cyclomatic 20) (pyrefly/lib/alt/class/class_field.rs)
- AnswersSolver::apply_literal (cognitive 24) (pyrefly/lib/alt/specials.rs)
- AnswersSolver::augassign_infer (cyclomatic 16) (pyrefly/lib/alt/operators.rs)
- AnswersSolver::binary_operator_order (cognitive 31) (pyrefly/lib/alt/operators.rs)
- AnswersSolver::binary_operator_order (cyclomatic 17) (pyrefly/lib/alt/operators.rs)
- AnswersSolver::call_infer_inner (cognitive 18) (pyrefly/lib/alt/call.rs)
- AnswersSolver::call_intersection (cognitive 32) (pyrefly/lib/alt/call.rs)
- AnswersSolver::call_intersection (cyclomatic 20) (pyrefly/lib/alt/call.rs)
- AnswersSolver::check_for_deprecated_call (cognitive 18) (pyrefly/lib/alt/expr.rs)
- AnswersSolver::check_for_deprecated_call (cyclomatic 18) (pyrefly/lib/alt/expr.rs)
- AnswersSolver::check_pydantic_model_validate_input (cognitive 46) (pyrefly/lib/alt/class/pydantic.rs)
- AnswersSolver::check_pydantic_model_validate_input (cyclomatic 26) (pyrefly/lib/alt/class/pydantic.rs)
- AnswersSolver::check_sqlalchemy_keyword_call (cognitive 17) (pyrefly/lib/alt/sqlalchemy.rs)
- AnswersSolver::collect_pydantic_constraint_params (cognitive 16) (pyrefly/lib/alt/class/pydantic.rs)
- AnswersSolver::completions (cognitive 48) (pyrefly/lib/alt/attr.rs)
- AnswersSolver::completions (cyclomatic 16) (pyrefly/lib/alt/attr.rs)
- AnswersSolver::completions_inner1 (cyclomatic 19) (pyrefly/lib/alt/attr.rs)
- AnswersSolver::constructor_to_callable (cyclomatic 17) (pyrefly/lib/alt/call.rs)
- AnswersSolver::dataclass_field_keywords (cognitive 19) (pyrefly/lib/alt/class/dataclass.rs)
- AnswersSolver::declared_bool_value (cognitive 45) (pyrefly/lib/alt/solve.rs)
- …and 481 more
Changes since last survey
- 300 commits — 290 feature/other, 10 fixes
By area
- pyrefly/lib — 133 commits
- tensor-shapes/pyrefly-torch-stubs — 94 commits
- (root) — 16 commits
- crates/pyrefly_config — 11 commits
- tensor-shapes/jax-pyrefly-stubs — 10 commits
- conformance/third_party — 8 commits
- crates/pyrefly_util — 6 commits
- .github/workflows — 4 commits
- tensor-shapes/pyrefly-numpy-stubs — 4 commits
- tensor-shapes/pyrefly-einops-stubs — 3 commits
- crates/pyrefly_types — 2 commits
- .agents/skills — 1 commit
- crates/pyrefly_build — 1 commit
- crates/pyrefly_python — 1 commit
- pyrefly/benches — 1 commit
- schemas/pyrefly.json — 1 commit
- scripts/benchmark — 1 commit
- website/docs — 1 commit
- website/src — 1 commit
- website/yarn.lock — 1 commit
Notable commits
- fix: Fix cascading errors when narrowing missing attributes (#5482)
- fix: Fix false-positive extra argument error for unknown-length *args with 0-param callables (#5555)
- fix: Fix slots class variable conflict (issue #5641) (#5642)
- fix: --report-glean fix: Name methods on Literal and LiteralString receivers by their class (#5605)
- fix: fix Completion returns no items inside a function body when the typed text is a keyword (as, in, is, ...) #5529 (#5617)
- fix: fix False negative: Pyrefly does not emit an unpacking error in for k, v in dict #3352 (#3353)
- fix: fix Pyrefly should narrow subsequent match cases after None case #3213 (#5585)
- fix: fix dunder all definition #4344 (#5586)
- fix: fix: report unreachable match case after a full class pattern (#5577)
- fix: jax-pyrefly-stubs: support DuckTypedArray in *_like and fix logsumexp/truncated_normal stubs (#5633)
- change: Accept Tensor.clone memory-format options
- change: Accept Torch torch.empty options and list sizes
- change: Accept SupportsIndex tensor indices, matching Torch
- change: Accept Tensor.item on any tensor
- change: Accept any input for nested Pydantic models with from_attributes
- change: Accept any input for nested Pydantic models with input-replacing model validators
- change: Accept integer lists in the interpolate size fallback
- change: Accept list dim in Tensor.mean and torch.mean
- change: Accept list dim in Tensor.sum and torch.sum
- change: Accept mixed-layout arrays in torch.from_numpy
- …and 280 more
Architecture
- Unchanged — 0 containers · 5 contexts · 0 edges
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
facebook/pyrefly was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 14 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit e4a2587978c306f54004d3ad6ee7e9622ce4f4a8 — the exact code this score is about.
- Scored under rubric-2026.11.4 — the same rubric and the same method as every other entry in this index.
- Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.65+preprod-e1a3b69fc8ee.