# TypeError: unsupported operand type(s) for -: 'str' and 'float'

- **ID:** `python/pytest-approx-comparison-error`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Using pytest.approx() with non-numeric types, such as comparing a string to a float, causing a type error.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   Ensure both operands are numeric: `assert pytest.approx(3.14) == float('3.14')`
   ```
2. **** (90% success)
   ```
   Convert the string to float explicitly: `assert pytest.approx(float('3.14'), 0.01) == 3.14`
   ```

## Dead Ends

- **** — pytest.approx() requires numeric types; string comparison does not support approximate matching. (85% fail)
- **** — This duplicates functionality of approx() and may still fail if types are mismatched. (70% fail)
