alecthomas / alecthomas/importmagic

Python 3 type hints for returned data

Ouverte
#55 0 commentaires 1 réaction 0 personnes assignées Voir sur GitHub
Langage dominant
Python
Étoiles
122
Forks
21
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

I ran across a potential issue with importmagic with a small test case that uses type hints, the following code seems to prompt importmagic to want to import 'data':

```python
import pandas as pd
from pandas import DataFrame

def test_loading_data_from_csv() -> None:
# if we remove the type hint for DataFrame importmagic returns an
# empty list of unresolved.
data: DataFrame = pd.DataFrame(columns=['User'])
assert data.shape == (0, 1)
```
when I run importmagic it claims 'data' and 'data.shape' are unresolved, here's the code I used to check the above and the results from running it at the command line:

```python
import sys
import importmagic

if __name__ == '__main__':
index = importmagic.SymbolIndex()
index.build_index(sys.path)
with open("importmagic_testcase.py") as file:
data = file.read()

scope = importmagic.Scope.from_source(data)
unresolved, unreferenced = scope.find_unresolved_and_unreferenced_symbols()
print(unresolved)

```
output is:
```
python -c "import sys;import runpy;sys.path.append('/home/dsyzling/projects/python/pandastest');runpy.run_path('/home/dsyzling/projects/python/pandastest/tests/run_importmagic_testcase.py', run_name='__main__')"
{'data', 'data.shape'}

```

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.