Azure / autorest.python

Extension for AutoRest (https://github.com/Azure/autorest) that generates Python code
MIT License
80 stars 57 forks source link

[Pylint] Useless-disable flagging on generated code #2802

Closed l0lawrence closed 2 weeks ago

l0lawrence commented 2 months ago

For next-pylint we have a new checker useless-suppression which warns when pylint thinks there is a #pylint:disable for no reason.

I merged this pr to add useless-suppression warning to this repo's pylintrc when we switched over to pylint-next.

It looks like we are hitting some useless-suppression on generated code like azure-ai-vision-face, and azure-ai... and azure-heath etc. Removing the disables and running pylint -- pylint is clean, so it looks like these warnings are valid.

What is the best way to go about this to resolve these warnings?

iscai-msft commented 2 months ago

Damn it's kind of hard to repro because I think we're already running useless-suppression in our pylintrc. Let me make sure we're actually running this in our pipelines. Just to confirm, these are tsp packages right?

l0lawrence commented 2 months ago

Thank you! Yes they are

iscai-msft commented 2 months ago

Ok we are getting the useless-suppression output, but pylint is still reporting us as 10

************* Module payload.multipart.operations._operations
generated/payload-multipart/payload/multipart/operations/_operations.py:1: [I0021(useless-suppression), ] Useless suppression of 'too-many-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:32: [I0021(useless-suppression), ] Useless suppression of 'ungrouped-imports'
generated/payload-multipart/payload/multipart/operations/_operations.py:33: [I0021(useless-suppression), ] Useless suppression of 'unsubscriptable-object'
generated/payload-multipart/payload/multipart/operations/_operations.py:167: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:180: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:246: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:259: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:325: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:338: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:404: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:417: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:483: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:496: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:562: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:575: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:643: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:654: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:729: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:742: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:811: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:824: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:893: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:906: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:975: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'
generated/payload-multipart/payload/multipart/operations/_operations.py:988: [I0021(useless-suppression), ] Useless suppression of 'inconsistent-return-statements'

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

@l0lawrence do you have any recs for how to make pylint fail in this case?

l0lawrence commented 1 month ago

Oo yes okay we can override the scoring to calculate in info warnings let me make a pr and link it

l0lawrence commented 1 month ago

https://github.com/Azure/autorest.python/pull/2813