ruff/crates/red_knot_python_semantic/resources/mdtest/mdtest_config.md
Dhruv Manilawala d082c1b202
[red-knot] Add missing imports in mdtests (#15869)
## Summary

Related to #15848, this PR adds the imports explicitly as we'll now flag
these symbols as undefined.

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2025-02-03 09:27:29 +00:00

1.3 KiB

This test makes sure that red_knot_test correctly parses the TOML configuration blocks and applies the correct settings hierarchically.

The following configuration will be attached to the root section (without any heading):

[environment]
python-version = "3.10"

Basic

Here, we simply make sure that we pick up the global configuration from the root section:

import sys

reveal_type(sys.version_info[:2] == (3, 10))  # revealed: Literal[True]

Inheritance

Child

Grandchild

The same should work for arbitrarily nested sections:

import sys

reveal_type(sys.version_info[:2] == (3, 10))  # revealed: Literal[True]

Overwriting

Here, we make sure that we can overwrite the global configuration in a child section:

[environment]
python-version = "3.11"
import sys

reveal_type(sys.version_info[:2] == (3, 11))  # revealed: Literal[True]

No global state

There is no global state. This section should again use the root configuration:

import sys

reveal_type(sys.version_info[:2] == (3, 10))  # revealed: Literal[True]

Overwriting affects children

Children in this section should all use the section configuration:

[environment]
python-version = "3.12"

Child

Grandchild

import sys

reveal_type(sys.version_info[:2] == (3, 12))  # revealed: Literal[True]