# Buggy code
def parse_pyproject_toml(path_config: str) -> Dict[str, Any]:
    """Parse a pyproject toml file, pulling out relevant parts for Black

    If parsing fails, will raise a toml.TomlDecodeError
    """
    pyproject_toml = toml.load(path_config)
    config = pyproject_toml.get("tool", {}).get("black", {})
    return {
        k.replace("--", "").replace("-", "_"): str(v)
        if not isinstance(v, (list, dict))
        else v
        for k, v in config.items()
    }


# Traceback (ImportError)
$ python -m unittest
E....[2020-06-14 14:22:15,341] DEBUG: Using selector: EpollSelector (selector_events.py:59)
.[2020-06-14 14:22:15,342] DEBUG: Using selector: EpollSelector (selector_events.py:59)
.[2020-06-14 14:22:15,680] DEBUG: Using selector: EpollSelector (selector_events.py:59)
.[2020-06-14 14:22:15,682] DEBUG: Using selector: EpollSelector (selector_events.py:59)
[2020-06-14 14:22:15,683] INFO: 16 projects to run Black over (lib.py:311)
[2020-06-14 14:22:15,683] DEBUG: Using 2 parallel workers to run Black (lib.py:316)
[2020-06-14 14:22:15,684] DEBUG: worker 0 working on aioexabgp (lib.py:247)
[2020-06-14 14:22:15,684] DEBUG: worker 0 working on attrs (lib.py:247)
[2020-06-14 14:22:15,684] DEBUG: worker 0 working on bandersnatch (lib.py:247)
[2020-06-14 14:22:15,684] DEBUG: worker 0 working on channels (lib.py:247)
[2020-06-14 14:22:15,684] DEBUG: worker 0 working on django (lib.py:247)
[2020-06-14 14:22:15,684] INFO: Skipping django as it's disabled via config (lib.py:254)
[2020-06-14 14:22:15,684] DEBUG: worker 0 working on flake8-bugbear (lib.py:247)
[2020-06-14 14:22:15,684] DEBUG: worker 0 working on hypothesis (lib.py:247)
[2020-06-14 14:22:15,684] DEBUG: worker 0 working on pandas (lib.py:247)
[2020-06-14 14:22:15,684] INFO: Skipping pandas as it's disabled via config (lib.py:254)
[2020-06-14 14:22:15,684] DEBUG: worker 0 working on poetry (lib.py:247)
[2020-06-14 14:22:15,684] DEBUG: worker 0 working on ptr (lib.py:247)
[2020-06-14 14:22:15,684] DEBUG: worker 0 working on pyramid (lib.py:247)
[2020-06-14 14:22:15,684] DEBUG: worker 0 working on pytest (lib.py:247)
[2020-06-14 14:22:15,684] INFO: Skipping pytest as it's disabled via config (lib.py:254)
[2020-06-14 14:22:15,684] DEBUG: worker 0 working on sqlalchemy (lib.py:247)
[2020-06-14 14:22:15,685] DEBUG: worker 0 working on tox (lib.py:247)
[2020-06-14 14:22:15,685] DEBUG: worker 0 working on virtualenv (lib.py:247)
[2020-06-14 14:22:15,685] DEBUG: worker 0 working on warehouse (lib.py:247)
[2020-06-14 14:22:15,685] DEBUG: project_runner 0 exiting (lib.py:245)
[2020-06-14 14:22:15,685] DEBUG: project_runner 1 exiting (lib.py:245)
[2020-06-14 14:22:15,685] INFO: Analyzing results (lib.py:327)
.
======================================================================
ERROR: tests.test_black (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: tests.test_black
Traceback (most recent call last):
File "/home/username/miniconda3/envs/ml4sts/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/home/username/miniconda3/envs/ml4sts/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/home/erik/black/tests/test_black.py", line 1766, in <module>
class BlackDTestCase(AioHTTPTestCase):
NameError: name 'AioHTTPTestCase' is not defined


----------------------------------------------------------------------
Ran 9 tests in 0.348s

FAILED (errors=1)

# Fixed code
def parse_pyproject_toml(path_config: str) -> Dict[str, Any]:
    """Parse a pyproject toml file, pulling out relevant parts for Black

    If parsing fails, will raise a toml.TomlDecodeError
    """
    pyproject_toml = toml.load(path_config)
    config = pyproject_toml.get("tool", {}).get("black", {})
    return {k.replace("--", "").replace("-", "_"): v for k, v in config.items()}