Pax
I want to replace the `query` of a `ParseResult` (which is a named tuple) but if I use `._replace()` Pylance will complain `"_replace" is protected and used outside of the class in which it is declared`
Ignoring Pylance is not an option. A solution I can think of:
```
ParseResult(
scheme=link.scheme,
netloc=link.netloc,
path=link.path,
params=link.params,
query="utm_source=newsource&utm_medium=newmedium",
fragment=link.fragment,
)
```
Is this the best way to do this? Or am I missing some Python idiom?
Top Answer
wizzwizz4
Pylance is wrong. Bypass it.
```python
replace = getattr(ParseResult, '_replace')
replace(link, query="utm_source=newsource&utm_medium=newmedium")
```