ApeWorX / ethpm-types

Implementation of EIP-2678
Apache License 2.0
14 stars 8 forks source link

Unable to have PackageName that uses all the valid characters [APE-1408] #89

Closed antazoey closed 1 year ago

antazoey commented 1 year ago

Environment information

Currently, you are not able to have a package name that contains all the valid characters, meaning every character in the alphabet at least once, and every digit at least once, and also the - (hyphen). If you try to do this, it will fail and tell you that you are using invalid characters even though you are not.

What went wrong?

Even though I am using all valid characters, it tells me I am not.

Example, when I do:

>>> PackageManifest(name="abcdefghijklmnopqrstuvwxyz0123456789-")

It results in:

pydantic.v1.error_wrappers.ValidationError: 2 validation errors for PackageManifest
name
  Characters in name must be one of a-z or 0-9 or '-' (type=assertion_error)

How can it be fixed?

Currently, the package name validator says this:

        assert set(value) < ALPHABET.union(NUMBERS).union(
            "-"
        ), "Characters in name must be one of a-z or 0-9 or '-'"
        return value

Simply changing the < to <= fixes the bug!

btw I am fixing this on my pydantic v2 upgrade, I just thought this bug was absolutely hilarious so I took the time to open this issue. LOL