Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeHintWaring when calling get_struct() method #129

Open
apkrelling opened this issue Oct 24, 2024 · 0 comments
Open

TypeHintWaring when calling get_struct() method #129

apkrelling opened this issue Oct 24, 2024 · 0 comments

Comments

@apkrelling
Copy link
Contributor

  • ASTx version: 0.15.0
  • Python version: 3.12.7
  • Operating System: Ubuntu 22.04

Description

Whenever the get struct() method gets called (I'm not sure if it's just this method or also others), I get some TypeHintWarnings, plus the expected output. This seems to have happened after merge of the PR #127 .

Code example:

from astx.packages import AliasExpr, ImportExpr

alias1 = AliasExpr(name="math")
alias2 = AliasExpr(name="matplotlib", asname="mtlb")

# Create an import statement
import_stmt = ImportStmt(names=[alias1, alias2])

import_stmt.get_struct()

output:

/home/anapaula/git_repos/astx/src/astx/base.py:209: TypeHintWarning: Cannot resolve forward reference 'astx.base.Undefined'
  return cast(ReprStruct, metadata)
/home/anapaula/git_repos/astx/src/astx/base.py:223: TypeHintWarning: Cannot resolve forward reference 'astx.base.Undefined'
  return cast(ReprStruct, struct)
/home/anapaula/git_repos/astx/src/astx/packages.py:193: TypeHintWarning: Cannot resolve forward reference 'astx.base.Undefined'
  return self._prepare_struct(key, value, simplified)
/home/anapaula/git_repos/astx/src/astx/base.py:211: TypeHintWarning: Cannot resolve forward reference 'astx.base.Undefined'
  def _prepare_struct(
/home/anapaula/git_repos/astx/src/astx/packages.py:224: TypeHintWarning: Cannot resolve forward reference 'astx.base.Undefined'
  return self._prepare_struct(key, value, simplified)

{'ImportStmt': {'content': [{'Alias [math]': {'content': '',
     'metadata': {'loc': {line: -1, col: -1},
      'comment': '',
      'ref': '',
      'kind': <ASTKind.AliasExprKind: -702>}}},
   {'Alias [matplotlib, mtlb]': {'content': '',
     'metadata': {'loc': {line: -1, col: -1},
      'comment': '',
      'ref': '',
      'kind': <ASTKind.AliasExprKind: -702>}}}],
  'metadata': {'loc': {line: -1, col: -1},
   'comment': '',
   'ref': '',
   'kind': <ASTKind.ImportStmtKind: -700>}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant