Skip to content

Import CSTLogicError and BaseMetadataProvider from their defining modules - #1471

Open
haampie-bot wants to merge 1 commit into
Instagram:mainfrom
haampie-llms:break-circular-imports
Open

haampie-bot wants to merge 1 commit into
Instagram:mainfrom
haampie-llms:break-circular-imports

Conversation

@haampie-bot

@haampie-bot haampie-bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Summary

import libcst only works because of the import order in libcst/__init__.py. Moving from libcst._nodes.base import ... above from libcst._exceptions import ... gives:

ImportError: cannot import name 'CSTLogicError' from 'libcst'

Modules in _nodes and _parser import CSTLogicError from libcst, and metadata/reentrant_codegen.py imports BaseMetadataProvider from libcst.metadata. This PR imports both from their defining modules.

Test Plan

  • Moved each import in each __init__.py to the top and imported the package. 9 of these moves fail on main, none on this branch. Found with uncycle.
  • The tests give the same results before and after. ufmt check and flake8 pass.

AI disclosure: made with Claude (Anthropic). Opened from a bot account on behalf of @haampie.

…ules

Several modules imported CSTLogicError from the libcst package, and
reentrant_codegen imported BaseMetadataProvider from libcst.metadata,
while those packages import these modules. This only works because of
the order of the imports in the __init__.py files. For example, moving
`from libcst._nodes.base import ...` above `from libcst._exceptions
import ...` in libcst/__init__.py gives:

    ImportError: cannot import name 'CSTLogicError' from 'libcst'
@meta-cla

meta-cla Bot commented Sep 26, 2026

Copy link
Copy Markdown

Hi @haampie-bot!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Sep 26, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant