Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Creates "from __main__" import for __main__ program

Open
#93 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
devtools

Research direction

Reproduce the issue with the shown t-pyannotate.py program and inspect the refactoring entry point that consumes type_info.json. Trace how the main.G sample becomes an import and annotation, then verify the generated refactor no longer creates an invalid from main import while retaining the type information.

Written by the indexing model from the issue text.

Description

bug

Given t-pyannotate.py:

from pyannotate_runtime import collect_types


collect_types.init_types_collection()
collect_types.start()


class G:
    pass


def c(obj):
    pass


c(G())

collect_types.stop()
collect_types.dump_stats("type_info.json")

Running and writing it produces the following diff, where it tries to import G from __main__ then:

--- t-pyannotate.py     (original)
+++ t-pyannotate.py     (refactored)
@@ -1,4 +1,5 @@
 from pyannotate_runtime import collect_types
+from __main__ import G


 collect_types.init_types_collection()
@@ -10,6 +11,7 @@


 def c(obj):
+    # type: (G) -> None
     pass

type_info.json:

[
    {
        "path": "t-pyannotate.py",
        "line": 8,
        "func_name": "G",
        "type_comments": [
            "() -> None"
        ],
        "samples": 1
    },
    {
        "path": "t-pyannotate.py",
        "line": 12,
        "func_name": "c",
        "type_comments": [
            "(__main__.G) -> None"
        ],
        "samples": 1
    }
]

pyannotate b7f96ca (current master).

Dominant language
Python
Stars
1.4k
Forks
59
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dropbox/pyannotate

All issues in dropbox/pyannotate

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.