Import Error: Failing to import file for classes that I've defined.

オープン
#789 コメント 9 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript, python
領域
compilers

調査の方向性

Reproduce the issue with transcrypt -v -n bezoar_sample.__main__ using the linked bezoar project and inspect the import chain ending at bezoar/model/relationship_declaration.py. Start with org/transcrypt/compiler.py, especially the visit_ClassDef area mentioned in the traceback, and compare the handling of entity.Entity with the related collections.abc import. Done means the sample imports compile without the reported missing-module errors and the regression is covered by a test.

索引モデルが issue の本文から書いたものです。

説明

Details

OS: Windows 10
Python Version: 3.9.6
Transcrypt version: 3.9.0

Summary

I'm trying to get my pure-Python project with no dependencies to be Transcrypt compatible, but ran into a problem very early with Import Errors for things that I don't understand. Specifically, names of functions or classes I'm importing are being reported as missing module files (examples below).

Steps to Reproduce
  1. git clone https://gitlab.com/iffyb/bezoar.git
  2. transcrypt -v -n bezoar_sample.__main__
Expected Results

It would import the function get_version and classes Entity and Player the way CPython does?

Actual Results
org.transcrypt.utils.Error: Error while compiling (offending file last):
        File 'C:/cygwin/home/iffy/ws/bezoar/bezoar_sample/__main__.py', line 5, at import of:
        File 'C:/cygwin/home/iffy/ws/bezoar/bezoar_sample/model.py', line 10, at import of:
        File 'C:/cygwin/home/iffy/ws/bezoar/bezoar/model/__init__.py', line 29, at import of:
        File 'C:/cygwin/home/iffy/ws/bezoar/bezoar/model/version_declaration.py', line 3, at import of:
        File 'C:/cygwin/home/iffy/ws/bezoar/bezoar/model/player_declaration.py', line 6, at import of:
        File 'bezoar.model.relationship_declaration', line 0, namely:

        Import error, can't find any of:
                C:/cygwin/home/iffy/ws/bezoar/bezoar/model/Entity.py
                C:/cygwin/home/iffy/ws/bezoar/bezoar/model/Entity.js
                c:/python/python39/lib/site-packages/transcrypt/modules/bezoar/model/Entity.py
                c:/python/python39/lib/site-packages/transcrypt/modules/bezoar/model/Entity.js
                C:/Python/Python39/Scripts/transcrypt.exe/bezoar/model/Entity.py
                C:/Python/Python39/Scripts/transcrypt.exe/bezoar/model/Entity.js
                C:/Users/iffy/AppData/Roaming/Python/Python39/site-packages/bezoar/model/Entity.py
                C:/Users/iffy/AppData/Roaming/Python/Python39/site-packages/bezoar/model/Entity.js
                c:/python/python39/lib/site-packages/bezoar/model/Entity.py
                c:/python/python39/lib/site-packages/bezoar/model/Entity.js

bezoar.model is a package, and Entity is a class defined in the bezoar.model.entity_declaration module, which has a file in C:/cygwin/home/iffy/ws/bezoar/bezoar/model/entity_declaration.py.

relationship_declaration imports bezoar.model.entity_declaration as entity and refers to entity.Entity, among several other symbols in the bezoar.model.entity_declaration module that it doesn't complain about.

Full transcript here: transcrypt_transcript.txt

Other Notes
  • It spits out many different Import Errors, some of them seemingly the same.
  • There's another internal except in the log, not sure how relevant it is:
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "c:\python/python39/lib/site-packages/transcrypt/modules\org\transcrypt\compiler.py", line 2028, in visit_ClassDef
        self.visit (statement.value)
      File "c:\python/python39/lib/site-packages/transcrypt/modules\org\transcrypt\compiler.py", line 985, in visit
        super () .visit (node)
      File "c:\python/python39/lib\ast.py", line 407, in visit
        return visitor(node)
      File "c:\python/python39/lib\ast.py", line 411, in generic_visit
        for field, value in iter_fields(node):
      File "c:\python/python39/lib\ast.py", line 249, in iter_fields
        for field in node._fields:
    AttributeError: 'NoneType' object has no attribute '_fields'  
    
  • The line number reported is "line 0" which seems odd.
  • There's also a similar-looking import error for from collections.abc import MutableMapping in bezoar.base.overlay_mapping
主要言語
Python
スター
2.9k
フォーク
218
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TranscryptOrg/Transcrypt のほかの issue

TranscryptOrg/Transcrypt の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。