Skip to content

refactor: remove the pytest.config compatibility kludge - #47

Merged
cigamit merged 1 commit into
ctrliq:mainfrom
blaipr:refactor/drop-pytest-config-kludge
Sep 13, 2026
Merged

cigamit merged 1 commit into
ctrliq:mainfrom
blaipr:refactor/drop-pytest-config-kludge

Conversation

@blaipr

@blaipr blaipr commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

ascenderkit/config.py carried this, and the comment is the whole story:

def getvalue(self, name):
    return self.__getitem__(name)

...

# kludge to mimic pytest.config
config.getvalue = types.MethodType(getvalue, config)

pytest.config was the global config object pytest exposed until it was removed in pytest 5.0, in 2019. This bound a method onto config so that code written against that API would keep working. Nothing here is written against it: config.getvalue has no caller in the package or the tests, and there is no dynamic access either, no getattr(config, 'getvalue') and no config['getvalue'].

It was redundant even when it worked. config is a PseudoNamespace, a dict subclass that already serves keys as attributes, so config.getvalue('host'), config['host'] and config.host were three spellings of one lookup. The thing the CLI actually uses for this is CLI.get_config, which reads the parsed --conf.xyz flags and is untouched.

Removes the function, the binding and the import types that existed only for it.

Verified with black --check, flake8 and the unit suite, 355 passing.

@ciq-it-service-account

ciq-it-service-account commented Sep 12, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

`ascenderkit/config.py` carried this, and the comment is the whole story:

```python
def getvalue(self, name):
    return self.__getitem__(name)

...

config.getvalue = types.MethodType(getvalue, config)
```

`pytest.config` was the global config object pytest exposed until it was removed in pytest 5.0, in 2019. This bound a method onto `config` so that code written against that API would keep working. Nothing here is written against it: `config.getvalue` has no caller in the package or the tests, and there is no dynamic access either, no `getattr(config, 'getvalue')` and no `config['getvalue']`.

It was redundant even when it worked. `config` is a `PseudoNamespace`, a `dict` subclass that already serves keys as attributes, so `config.getvalue('host')`, `config['host']` and `config.host` were three spellings of one lookup. The thing the CLI actually uses for this is `CLI.get_config`, which reads the parsed `--conf.xyz` flags and is untouched.

Removes the function, the binding and the `import types` that existed only for it.

Verified with `black --check`, `flake8` and the unit suite, 355 passing.
@blaipr
blaipr force-pushed the refactor/drop-pytest-config-kludge branch from 152d282 to 7fdc894 Compare September 13, 2026 09:03
@cigamit
cigamit merged commit 73da85c into ctrliq:main Sep 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants