PyCQA / PyCQA/isort

`add_imports` + `append_only` inserts future import in illegal position

Open
#1,970 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7k
Forks
687
Avg merge
4h 56m
Merged PRs (30d)
2

Description

#!/usr/bin/env python3

if __name__ == '__main__':
    import gevent.monkey
    gevent.monkey.patch_all()

import sys

print('silly example', file=sys.stderr)
$ isort --diff --append-only --add-import 'from __future__ import annotations' t.py
--- /tmp/y/t.py:before	2022-09-14 11:34:27.398068
+++ /tmp/y/t.py:after	2022-09-14 11:34:31.624185
@@ -4,6 +4,8 @@
     import gevent.monkey
     gevent.monkey.patch_all()
 
+from __future__ import annotations
+
 import sys
 
 print('silly example', file=sys.stderr)

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Reproduce the issue with the shown Python example and the isort --diff --append-only --add-import command. Trace the append_only and add_import entry points, then add a regression test showing that the future import is placed legally and run the relevant test suite.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.