microsoft / microsoft/typespec

[Bug]: Python emitter moves my `# pylint: disable=protected-access` around in _patch.py, make it no longer effective

Open
#5,583 0 comments 0 reactions 0 assignees View on GitHub
bug emitter:client:python
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

### Describe the bug

I added the line `# pylint: disable=protected-access` in my _patch.py file to make a Pylint error go away. Note that it has to be in the same line as where the property is accessed, otherwise the error will not go away.

After re-emitting from TypeSpec, I see that _patch.py was edited, and the emitter decided to move `# pylint: disable=protected-access` to the end of the multi-line instruction. That results in the Pylint error appearing again.

Is there a way to fix the emitter to not do that? Thanks!

(and BTW the original multi-line instruction is a result of running the black tool `black --config ../../../eng/black-pyproject.toml .` It was the one who broke the line into multiple lines)

Screenshot of the diff after re-emitting:

![Image](https://github.com/user-attachments/assets/37e6f339-d308-48ce-bc78-39c18ce1cced)

### Reproduction

See above

### Checklist

- [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
- [x] Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- [x] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/Microsoft/typespec/discussions).
- [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.