6

I have the PyCharm inspection enabled for duplicated code fragment (Inspections --> General --> Duplicated code fragment).

I am trying to use a noinspection tag to locally disable this inspection in my Python code. However, I can't figure out the noinspection tag. It's not documented in my usual source: pylover/inspections.txt

Does anyone know it?


What I Have Tried

Options that don't work:

  • # noinspection Duplicates
  • //noinspection Duplicates (this is not for Python)
  • # SuppressWarnings("Duplicates")
  • # noinspection DuplicatedCode (from JetBrains YouTrack PY-38309)

Is it possible to disable duplicate code detection in Intellij?

I do not want to uncheck the inspection, I just want to be able to locally suppress it.

I also tried running the command documented in pylover/inspections.txt:

unzip -p lib/pycharm.jar com/jetbrains/python/PyBundle.properties | grep -B1 INSP.NAME | grep '^#' | sed 's|Inspection||g' | sed -e 's|#\s\{,1\}|# noinspection |'

And I didn't see any mentions of duplicates there.


Versions

  • OS: macOS Mojave 10.14.3
  • Python: 3.6.5
  • PyCharm: 2020.1 PE
Intrastellar Explorer
  • 3,005
  • 9
  • 52
  • 119

1 Answers1

2

I don't know if you've found a solution to your problem, but # noinspection DuplicatedCode works for me.


Versions

  • OS: macOS Monterey 12.3.1
  • Python: 3.9.11
  • PyCharm: 2022.1 PE
Milo Parigi
  • 1,009
  • 7
  • 10