MCPcopy Create free account
hub / github.com/PyCQA/isort / configs

Function configs

tests/integration/test_hypothesmith.py:36–69  ·  view source on GitHub ↗

Generate arbitrary Config objects.

(**force_strategies: st.SearchStrategy)

Source from the content-addressed store, hash-verified

34
35
36def configs(**force_strategies: st.SearchStrategy) -> st.SearchStrategy:
37 """Generate arbitrary Config objects."""
38 skip = {
39 "line_ending",
40 "sections",
41 "known_future_library",
42 "forced_separate",
43 "lines_before_imports",
44 "lines_after_imports",
45 "lines_between_sections",
46 "lines_between_types",
47 "sources",
48 "virtual_env",
49 "conda_env",
50 "directory",
51 "formatter",
52 "formatting_function",
53 }
54 inferred_kwargs = {
55 k: st.from_type(v)
56 for k, v in get_type_hints(isort.settings._Config).items()
57 if k not in skip
58 }
59 specific = {
60 "line_length": st.integers(0, 200),
61 "wrap_length": st.integers(0, 200),
62 "indent": st.integers(0, 20).map(lambda n: n * " "),
63 "default_section": st.sampled_from(sorted(isort.settings.KNOWN_SECTION_MAPPING)),
64 "force_grid_wrap": st.integers(0, 20),
65 "profile": st.sampled_from(sorted(isort.settings.profiles)),
66 "py_version": st.sampled_from(("auto", *isort.settings.VALID_PY_TARGETS)),
67 }
68 kwargs = {**inferred_kwargs, **specific, **force_strategies}
69 return st.fixed_dictionaries({}, optional=kwargs).map(_as_config)
70
71
72st.register_type_strategy(isort.Config, configs())

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected