title: In pylint is there a way to locally disable a warning and then undo the previous suppression without explicitly giving a list?
body: <p>I am aware of the <a href="http://docs.pylint.org/faq.html#is-there-a-way-to-disable-a-message-for-a-particular-module-only" rel="nofollow">FAQ</a> entry for PyLint which states that:</p>
  
  <blockquote>
    <h3>4.2 Is there a way to disable a message for a particular module only?</h3>
    
    <p>Yes, you can disable or enable (globally disabled) messages at the
    module level by adding the corresponding option in a comment at the
    top of the file:</p>
  
  <pre><code># pylint: disable=wildcard-import, method-hidden
  # pylint: enable=too-many-lines
  </code></pre>
  </blockquote>
  
  <p>However, how can I locally suppress a message and then simply restore the previous state, prior to suppression. I don't want to have to repeat myself when restoring the previous state. Is there a way to achieve this?</p>
  
  <p>A shortcoming of the way PyLint handles this appears to be that if I disable a particular message <code>some-message</code> globally (e.g. command line or <code>pylintrc</code>) and then I have the following Python code segment:</p>
  
  <pre><code># pylint: disable=some-message
  foo, bar, baz = 0, 1, 2
  # ... the code that creates the warning
  # pylint: enable=some-message
  </code></pre>
  
  <p>the documentation suggests that the first line would not have any effect (i.e. the already disabled message would remain disabled) while the last line would undo not just the local effect of the first line - whether it was benign or not due to global settings - but would also undo the command line option or <code>pylintrc</code> setting.</p>
  
  <p>What I am looking for is a functionality similar to that in MS Visual C++ for warnings:</p>
  
  <pre><code>#pragma warning(push) /* save current state of warning settings */
  #pragma warning(disable:somewarning)
  /* warning occurs in code here */
  #pragma warning(pop)  /* restore previous state of warning settings */
  </code></pre>
  
  <p>an more concise alternative is:</p>
  
  <pre><code>#pragma warning(disable:somewarning)
  /* warning occurs in code here */
  #pragma warning(default:somewarning)
  </code></pre>
  
  <p>Does either functionality exist in PyLint?</p>