Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9133475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:29:44+00:00 2026-06-17T08:29:44+00:00

suppose I have the code def foo(): bar = 1 wibble = 3 return

  • 0

suppose I have the code

def foo():
    bar = 1
    wibble = 3
    return locals()

my current syntax checker (flake8 with syntastic.vim) will throw a ‘assigned to but never used’ error on both variables. However locals() implies something is they are in fact being used, if not explicitly.

def foo():
    bar = 1
    wibble = 3 # <-- I still want this to throw as it is definitely not being used
    return bar

Is there any python checker or custom setting that will be locals() aware and lenient?

EDIT:

This is a quick and dirty solution for vim/syntastic/flake8 that will suppress the warning in your .vimrc

"Ignore unused variable warnings whenever locals() is being used in a file                                                              
function! LocalsWarningSuppress()                                              
    if ( search("locals()",'nw') > 0)                                          
        let g:syntastic_python_checker='flake8 --ignore=W806'                  
    else                                                                       
        let g:syntastic_python_checker='flake8'                                
    endif                                                                      
endfunction 

au BufWritePre **/(filter_pattern)*py call LocalsWarningSuppress()                 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:29:45+00:00Added an answer on June 17, 2026 at 8:29 am

    No. Even pylint, the most powerful and nitpicky Python linter I’m aware of, isn’t clever enough to detect this case. But if it were, it would probably complain that you’re using locals() in the first place. 🙂

    On the other hand, and unlike pyflakes, pylint does support magic comments to ignore specific problems. But I must warn you that pylint is extremely picky (and thus slow) out of the box, so you’ll want to spend a few minutes upfront to cut its list of checks down to just the things you actually care about.

    There is a ticket closed as wontfix for improving this behavior in the specific case of string formatting. It appears that pylint developers don’t want to implement this as a feature.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have the following code: case class Foo(x: SortedSet[String]) { def bar: Set[String]
For example, suppose I have the code: class Foo(object): def bar(self, x): '''blah blah
Suppose I have following code: def foo(s): A dummy function foo. For example: >>>
Suppose I have following code def foo(x:Int):Unit = { if (x == 1) println
Suppose we have the following class hierarchy: class ClassA: @property def foo(self): return hello
Suppose I have the following Scala code: class Foo(a: Int) class Bar(b: Buffer[Int]) extends
Suppose I have this code: class Example(object): def the_example(self): itsProblem = "problem" theExample =
Suppose I have the following python code: def outer(): string = def inner(): string
Suppose we have following code defined in tester.py class Tester( object ): def method(
Suppose I have this code: class Num: def __init__(self,num): self.n = num def getn(self):

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.