<!--
Generated by the pyrx RPG docs pipeline from ../../.rpg/rpg_encoder.json.
Do not edit directly — changes will be overwritten by the next refresh.
Graph repo_sha: 784698179a5627072df39bbe0fcadb55bb7dd408
Graph generated_at: 2026-06-10T00:19:36.841Z
-->
# Constraint Solving and Type Variables

**Feature path:** `Constraint Solving and Type Variables`

## Implementation summary

- **Files:** 3
- **Symbols:** 57

### Primary files

These are the main implementation files attached to this semantic node.

| File | Summary |
| ---- | ------- |
| [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts#L1-L90) | Holds mappings from type variables to resolved types and manages multiple constraint solution sets |
| [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts#L1-L1450) | Solves TypeVar, TypeVarTuple, and ParamSpec constraints to infer concrete types based on collected constraints |
| [packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts#L1-L288) | Tracks and manages constraint sets and bounds for type variables used by the constraint solver |

### Symbol preview (40 of 57)

| Symbol | Kind | Source |
| ------ | ---- | ------ |
| `ConstraintSolutionSet` | class | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts#L15-L51) |
| `ConstraintSolutionSet.isEmpty` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts#L23-L25) |
| `ConstraintSolutionSet.getType` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts#L29-L32) |
| `ConstraintSolutionSet.setType` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts#L34-L37) |
| `ConstraintSolutionSet.hasType` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts#L39-L42) |
| `ConstraintSolutionSet.doForEachTypeVar` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts#L44-L50) |
| `ConstraintSolution` | class | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts#L53-L89) |
| `ConstraintSolution.isEmpty` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts#L61-L63) |
| `ConstraintSolution.setType` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts#L65-L69) |
| `ConstraintSolution.getMainSolutionSet` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts#L71-L73) |
| `ConstraintSolution.getSolutionSets` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts#L75-L77) |
| `ConstraintSolution.doForEachSolutionSet` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts#L79-L83) |
| `ConstraintSolution.getSolutionSet` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolution.ts#L85-L88) |
| `assignTypeVar` | function | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts#L90-L215) |
| `solveConstraints` | function | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts#L218-L231) |
| `applySourceSolutionToConstraints` | function | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts#L234-L249) |
| `solveConstraintSet` | function | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts#L251-L264) |
| `solveTypeVarRecursive` | function | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts#L266-L327) |
| `addConstraintsForExpectedType` | function | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts#L335-L512) |
| `stripLiteralsForLowerBound` | function | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts#L514-L518) |
| `getTypeVarType` | function | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts#L520-L574) |
| `assignBoundTypeVar` | function | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts#L579-L618) |
| `assignUnconstrainedTypeVar` | function | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts#L622-L1005) |
| `assignConstrainedTypeVar` | function | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts#L1008-L1198) |
| `assignParamSpec` | function | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts#L1201-L1309) |
| `typeVarOccursIn` | function | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts#L1317-L1342) |
| `widenTypeForTypeVarTuple` | function | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts#L1347-L1375) |
| `stripLiteralValueForUnpackedTuple` | function | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts#L1379-L1404) |
| `logConstraints` | function | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts#L1408-L1420) |
| `logTypeVarConstraintSet` | function | [packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintSolver.ts#L1422-L1449) |
| `ConstraintSet` | class | [packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts#L40-L183) |
| `ConstraintSet.clone` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts#L57-L69) |
| `ConstraintSet.isSame` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts#L71-L97) |
| `ConstraintSet.isEmpty` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts#L99-L101) |
| `ConstraintSet.getScore` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts#L105-L123) |
| `ConstraintSet.setBounds` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts#L125-L133) |
| `ConstraintSet.doForEachTypeVar` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts#L135-L137) |
| `ConstraintSet.getTypeVar` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts#L139-L142) |
| `ConstraintSet.getTypeVars` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts#L144-L152) |
| `ConstraintSet.addScopeId` | method | [packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts](https://github.com/microsoft/pyrx/blob/784698179a5627072df39bbe0fcadb55bb7dd408/packages/pyright/packages/pyright-internal/src/analyzer/constraintTracker.ts#L154-L160) |
| _17 additional symbols omitted_ |  |  |

## Dependencies

**Imported by:**

- `packages/pyright/packages/pyright-internal/src/analyzer/checker.ts`
- `packages/pyright/packages/pyright-internal/src/analyzer/constructorTransform.ts`
- `packages/pyright/packages/pyright-internal/src/analyzer/constructors.ts`
- `packages/pyright/packages/pyright-internal/src/analyzer/dataClasses.ts`
- `packages/pyright/packages/pyright-internal/src/analyzer/patternMatching.ts`
- `packages/pyright/packages/pyright-internal/src/analyzer/properties.ts`
- `packages/pyright/packages/pyright-internal/src/analyzer/protocols.ts`
- `packages/pyright/packages/pyright-internal/src/analyzer/tuples.ts`
- `packages/pyright/packages/pyright-internal/src/analyzer/typeEvaluator.ts`
- `packages/pyright/packages/pyright-internal/src/analyzer/typeEvaluatorTypes.ts`
- `packages/pyright/packages/pyright-internal/src/analyzer/typeGuards.ts`
- `packages/pyright/packages/pyright-internal/src/analyzer/typeUtils.ts`
- `packages/pyright/packages/pyright-internal/src/analyzer/typedDicts.ts`

**Imports:**

- `packages/pyright/packages/pyright-internal/src/analyzer/typeComplexity.ts`
- `packages/pyright/packages/pyright-internal/src/analyzer/typeEvaluatorTypes.ts`
- `packages/pyright/packages/pyright-internal/src/analyzer/typeUtils.ts`
- `packages/pyright/packages/pyright-internal/src/analyzer/types.ts`
- `packages/pyright/packages/pyright-internal/src/common/debug.ts`
- `packages/pyright/packages/pyright-internal/src/common/diagnostic.ts`
- `packages/pyright/packages/pyright-internal/src/localization/localize.ts`
