Skip to content

breaks on type annotation for class attribute #85

Closed

Description

@dz0
class SimpleHttpTask(Task):
    """Very simple/naive"""

    url = None
    method = "GET"
    client: requests.Session = requests.Session()

Pynsource couldn't handle traversing AST in file /Users/jpralgauskis/IdeaProjects/kettle/kettle/task/http.py corresponding to approx. lineno 18 coloffset 4 - source code:

client: requests.Session = requests.Session()

Please report this to https://github.com/abulka/pynsource/issues

Log file location:
/users/jpralgauskis/library/logs/pynsource/debug.log
debug.log

Actual exception:

'Attribute' object has no attribute 'id'

Activity

  1. abulka commented on Jun 3, 2021

    @abulka
    Owner

    Thanks for reporting this - please try running the latest master using Python 3.8 or higher. I need to update the binary releases from Python 3.7 to Python 3.8 sometime.

  2. abulka commented on Jun 29, 2021

    @abulka
    Owner
    @unittest.skipIf(sys.version_info.minor < 8, 'Need to upgrade Pynsource to run in Python 3.8 to handle this syntax')
    def test_issue_class_type_annotation_85(self):
        """This seems to pass OK under Python 3.9
        Hmm - perhaps this error only happens with lower version of
        Python - will need to check. As it stands, it looks promising 
        that no changes to the Pynsource parser are needed, 
        only a Python version bump. That is, assuming the 
        source code reproduces the problem.
        """
        source_code = dedent("""
            class SimpleHttpTask(Task):
                url = None
                method = "GET"
                client: requests.Session = requests.Session()
        """
        )
        pmodel, debuginfo = parse_source(source_code, 
                                            options={"mode": 3}, 
                                            html_debug_root_name="test_issue_class_type_annotation_85")
        self.assertNotIn("error", pmodel.errors)

    Further testing is pending.

  3. added a commit that references this issue on Jun 29, 2021
  4. added a commit that references this issue on Jul 1, 2021
  5. abulka commented on Jul 8, 2021

    @abulka
    Owner

    Latest master branch and 1.78 beta binary release should have fixed this.
    Official 1.78 release only a few days away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions