0

I'd like to disable a pylint error message which is a false positive, but the code base I'm working with already has an existing type hint disable...

    import zoneinfo  # type: ignore[no-redef]

I know I can disable a specific line by putting the disable at the end and so if the type hint disable were not in place I would...

    import zoneinfo  # pylint: disable=import-error

I found this useful thread and see that I can disable multiple pylint errors for a specific line (not something I'd clocked before) but checking the PyLint : Message Control do not see a method of combining disabling of type hints and pylint on the same line.

Should I instead encapsulate the line like so...

    # pylint: disable=import-error
    import zoneinfo  # type: ignore[no-redef]
    # pylint: enable=import-error

It is the last import in the specific file so in theory I shouldn't need to enable it again but would like to protect users in the future and was curious if there was a better way.

slackline
  • 2,295
  • 4
  • 28
  • 43

0 Answers0