Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

TypeError: %d format: a number is required, not _Yes #7

Open
kostikvento opened this issue Oct 9, 2011 · 1 comment
Open

TypeError: %d format: a number is required, not _Yes #7

kostikvento opened this issue Oct 9, 2011 · 1 comment

Comments

@kostikvento
Copy link

Hello,

Here's what I get when using django-lint on Ubuntu 10.10 installed either from package or from git-cloned code:

Traceback (most recent call last):
File "./django-lint", line 25, in
sys.exit(script.main())
File "/home/kostik/distr/django-lint/DjangoLint/script.py", line 139, in main
linter.check([target])
File "/usr/lib/pymodules/python2.6/pylint/lint.py", line 488, in check
self.check_astng_module(astng, walker, rawcheckers)
File "/usr/lib/pymodules/python2.6/pylint/lint.py", line 563, in check_astng_module
walker.walk(astng)
File "/usr/lib/pymodules/python2.6/pylint/utils.py", line 516, in walk
self.walk(child)
File "/usr/lib/pymodules/python2.6/pylint/utils.py", line 516, in walk
self.walk(child)
File "/usr/lib/pymodules/python2.6/pylint/utils.py", line 516, in walk
self.walk(child)
File "/usr/lib/pymodules/python2.6/pylint/utils.py", line 513, in walk
cb(astng)
File "/home/kostik/distr/django-lint/DjangoLint/AstCheckers/model_fields.py", line 154, in visit_callfunc
self.config.max_charfield_length,
File "/usr/lib/pymodules/python2.6/pylint/checkers/init.py", line 92, in add_message
self.linter.add_message(msg_id, line, node, args)
File "/usr/lib/pymodules/python2.6/pylint/utils.py", line 265, in add_message
msg %= args
TypeError: %d format: a number is required, not _Yes

@thomasf
Copy link

thomasf commented Sep 23, 2012

I got this too. When my max_length isnt a interger but a reference to a configuration variable the following output fails because the first %d is actually a string.

        'W6007': (
            '%s: CharField with huge (%d/%d) max_length instead of TextField',
        ''),

The following snippet wll trigger the error:

class AbstractField(models.Model):
    """
    A field for a user-built form.
    """
    label = models.CharField(_(u"Namn"), max_length=settings.LABEL_MAX_LENGTH, help_text=u"Fältets titel...")

I currently do not have any time right now to dive into pylint an so on but this problem should be reproduceable now at least.

@thomasf thomasf mentioned this issue Nov 8, 2012
grumbler added a commit to grumbler/django-lint that referenced this issue Sep 19, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants