Skip to content

Conversation

@tawsifkamal
Copy link
Contributor

Motivation

  • Checks if the import is dynamic by checking if it's in the body of a function, method, if statement, etc
  • Supports TSImport and PyImport

@linear
Copy link

linear bot commented Jan 28, 2025

CG-9706 Support `import.is_dynamic`

  • Would be great to be able to say an import is top-level or not
  • Same for JS - not have to mess with the edge cases here

See implementation here: https://www.codegen.sh/codemod/4897/code/22013/playground/diff

Make sure to update the docs! ("Imports and Exports")

This should enable us to detect this import in python:

if TYPE_CHECKING:
  from codegen import Codebase

def my_function():
  from codegen import MyFunction

Bonus: support JS! (what does this look like?)

@tawsifkamal tawsifkamal reopened this Jan 28, 2025
@tawsifkamal tawsifkamal merged commit 86189ed into develop Jan 28, 2025
9 of 14 checks passed
@tawsifkamal tawsifkamal deleted the tawsif-import-is-dynamic branch January 28, 2025 21:29
jayhack pushed a commit that referenced this pull request Feb 9, 2025
# Motivation
<!-- Why is this change necessary? -->
- Checks if the import is dynamic by checking if it's in the body of a
function, method, if statement, etc
- Supports TSImport and PyImport

---------

Co-authored-by: codegen-bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants