alecthomas / alecthomas/importmagic

Imports block detection needs to be smarter

Đang mở
#8 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
Python
Star
122
Fork
21
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

The current imports block detection need to be improved, for example, this is a typical and common import block in applications that supports several versions of some library or different versions of python even:

``` python
try:
import ujson as json
except ImportError:
import json

from collections import defaultdict
import sys

def main():
print(os.uname())
a = defaultdict(list)
```

This is translated to

``` python
import json
import sys
from collections import defaultdict

import ujsonas json

try:
import ujson as json
except ImportError:
import json

from collections import defaultdict
import sys

def main():
print(os.uname())
a = defaultdict(list)
```

That is a complete disaster, in the other hand, the scope is fine:

```
print(scope.find_unresolved_and_unreferenced_symbols())
(set(['os.uname']), set(['sys', 'json', 'main']))
```

The importer has no clue about what is really imported in the file as its not able to know where the imports block really ends.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.