Skip to content

[Discussion] Issue with importing "-" packages either on the same level or nested. #1266

Closed

Description

@dennybaa

Hello @Peefy , I continue to enjoy my learning of KCL)

Yet met another minor bug in import, which you might be aware of... If issue with importing modules has been resolved, I'm successfully able to import artifathub modules with dashes in name. Local packages seem to misbehave.

1. Minimal reproduce step (Required)

tree
.
├── a-b.k
├── a.k
├── kcl.mod
└── kcl.mod.lock

a.k:

# It actually could be import nested.a_b (in case file is nested/a-b.k)
import .a_b
output = a_b.hello

kcl.mod:

[package]
name = "iaas-alerting"
edition = "v0.8.0"
version = "0.0.1"

[dependencies]
victoria-metrics-operator = { oci = "oci://ghcr.io/kcl-lang/victoria-metrics-operator", tag = "0.0.1" }
k8s = { oci = "oci://ghcr.io/kcl-lang/k8s", tag = "1.28" }

4. What is your KCL components version? (Required)

0.8.7

Thank you and have a great day @Peefy !

Activity

  1. Peefy commented on May 2, 2024

    @Peefy
    Contributor

    Yes. Local packages are yet not supported. It is just a little like python, we can use the pip package that contains - but we can not import local package contains -

  2. changed the title [-][bug] Issue with importing "-" packages either on the same level or nested.[/-] [+][Discussion] Issue with importing "-" packages either on the same level or nested.[/+] on May 2, 2024
  3. dennybaa commented on May 2, 2024

    @dennybaa
    Author

    I see, getting best of python, doesn't necessary mean that kcl import system should resemble this behavior. For the perspective of uniform behavior import of remote modules or local packages could behave the same way, i.e. it works for remote and it works for local the same way...

    Though it's not clear how to differentiate a_b.k and a-b.k :))) without a failure... It would be nice if KCL blended best from Go and Python... Namely go like import system could look better:

    import (
    "pkg.a-k" as ak
    "pkg.a_k" as a_k
    )

    But this is all preferences...

  4. locked and limited conversation to collaborators on May 4, 2024
  5. converted this issue into a discussion #1273 on May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions