1. PyPA
  2. Python Packaging Authority Projects
  3. pypi
  4. Issues

Issues

Issue #107 resolved

PyTidy 1.22 -- Attribute Error if code contains dict/set comprehension

Thomas Keck
created an issue

PyTidy raises an AttributeError if the code I want to format contains dict/set comprehensions.

The line causing the error in my code look like this:

#!python
dependencies = { pdg : filter(lambda x: x not in stages[-1], d) for (pdg,d) in dependencies.iteritems() if len(d) > 0}

Here are two minimal examples reproducing the error. Or two be correct, two different errors! But I guess both error have the same origin.

#!python

user@host:~/PythonTidy$ echo "a = { 1 }" | ./PythonTidy-1.22.python
#!/usr/bin/python
# -*- coding: utf-8 -*-
Traceback (most recent call last):
  File "./PythonTidy-1.22.python", line 4823, in <module>
    tidy_up(file_in, file_out)
  File "./PythonTidy-1.22.python", line 4801, in tidy_up
    module.push_scope().marshal_names().put().pop_scope()
  File "./PythonTidy-1.22.python", line 3864, in put
    self.node.put()
  File "./PythonTidy-1.22.python", line 4331, in put
    node.put()
  File "./PythonTidy-1.22.python", line 2307, in put
    self.expr.put(can_split=can_split)
AttributeError: Set instance has no attribute 'put'

user@host:~/PythonTidy$ echo "{ 1 }" | ./PythonTidy-1.22.python
Traceback (most recent call last):
  File "./PythonTidy-1.22.python", line 4823, in <module>
    tidy_up(file_in, file_out)
  File "./PythonTidy-1.22.python", line 4801, in tidy_up
    module.push_scope().marshal_names().put().pop_scope()
  File "./PythonTidy-1.22.python", line 3876, in marshal_names
    self.node.marshal_names()
  File "./PythonTidy-1.22.python", line 4345, in marshal_names
    node.marshal_names()
  File "./PythonTidy-1.22.python", line 2845, in marshal_names
    self.expr.marshal_names()
AttributeError: Set instance has no attribute 'marshal_names'

I'm using Python 2.7.3.

Best regards, Thomas

Comments (1)

  1. Log in to comment