```python
def read_config(text: str) -> dict[str, str]:
    config = {}
    for line in text.splitlines():
        if line.strip() and not line.startswith('#'):
            parts = line.split('=', 1)
            if len(parts) != 2:
                raise ValueError(f"Invalid line format: {line}")
            key, value = parts
            config[key.strip()] = value.strip()
    return config
```