Conversation
…rns for validation.
There was a problem hiding this comment.
Pull request overview
This pull request enhances the constants module by adding new enumerations for environment configuration and localization, along with comprehensive regex patterns for input validation. These additions provide standardized constants for common use cases like environment types, language codes, currency codes, and various validation patterns.
Changes:
- Added three new enum classes:
EnvEnumfor deployment environments,LanguageEnumfor supported languages, andCurrencyEnumfor supported currencies - Added multiple alphanumeric regex patterns including variants with Korean and Mongolian character support
- Added regex patterns for HTTP methods, asymmetric algorithms, and JWT algorithms
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/potato_util/constants/_enum.py | Added EnvEnum, LanguageEnum, and CurrencyEnum classes with proper exports in all |
| src/potato_util/constants/_regex.py | Added 12 new alphanumeric validation regex patterns and 3 new algorithm/method validation patterns with proper exports in all |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ALPHANUM_KR_MN_HYPHEN_REGEX = r"^[0-9a-zA-Z가-힣А-яҮүӨөЁё_\-]+$" | ||
| ALPHANUM_KR_MN_HOST_REGEX = r"^[0-9a-zA-Z가-힣А-яҮүӨөЁё_\-.]+$" | ||
| ALPHANUM_KR_MN_EXTEND_REGEX = r"^[0-9a-zA-Z가-힣А-яҮүӨөЁё_\-. ]+$" | ||
| ALPHANUM_KR_MN_PATH_REGEX = r"^[0-9a-zA-Z가-힣А-яҮүӨөЁё_\-. \\\/]+$" |
There was a problem hiding this comment.
Similar to the previous patterns, the hyphen character in the character class is unnecessarily escaped with a backslash. Consider changing '-' to '-' for cleaner regex patterns. This applies to all Korean/Mongolian patterns (lines 11-14).
| en = "en" | ||
| ko = "ko" | ||
| mn = "mn" | ||
| uz = "uz" |
There was a problem hiding this comment.
The LanguageEnum uses lowercase for enum member names (en, ko, mn, uz) which deviates from the typical Python enum naming convention. While lowercase is correct for the ISO 639-1 language code values, the enum member names themselves typically follow uppercase conventions as seen in most other enums in this file (WarnEnum, TSUnitEnum, ConfigFileFormatEnum). Consider using uppercase member names mapped to lowercase values: EN = "en", KO = "ko", MN = "mn", UZ = "uz". Note that HashAlgoEnum uses lowercase member names because that's the standard name for hash algorithms, but language codes are different - the code is lowercase but the constant name can be uppercase.
| en = "en" | |
| ko = "ko" | |
| mn = "mn" | |
| uz = "uz" | |
| EN = "en" | |
| KO = "ko" | |
| MN = "mn" | |
| UZ = "uz" |
| ALPHANUM_HYPHEN_REGEX = r"^[0-9a-zA-Z_\-]+$" | ||
| ALPHANUM_HOST_REGEX = r"^[0-9a-zA-Z_\-.]+$" | ||
| ALPHANUM_EXTEND_REGEX = r"^[0-9a-zA-Z_\-. ]+$" | ||
| ALPHANUM_PATH_REGEX = r"^[0-9a-zA-Z_\-. \\\/]+$" |
There was a problem hiding this comment.
The hyphen character in the character class is unnecessarily escaped with a backslash. Within a character class, hyphens only need to be escaped if they could be interpreted as a range operator (i.e., when between two characters). Since the hyphen appears after an underscore and backslash here, it's already unambiguous and the escape is redundant. Consider changing '-' to '-' for cleaner regex patterns. This applies to all similar patterns in this file (lines 4-7, 11-14).
This pull request expands the constants module by introducing new enums for environment, language, and currency, as well as adding a comprehensive set of regex patterns for input validation. These changes improve the clarity and maintainability of configuration and validation logic across the codebase.
New enums for configuration and localization:
EnvEnumto represent various deployment environments such as LOCAL, DEVELOPMENT, TEST, DEMO, DOCS, STAGING, and PRODUCTION.LanguageEnumandCurrencyEnumto standardize supported languages (en, ko, mn, uz) and currencies (USD, KRW, MNT, UZS).Regex patterns for input validation:
__all__list insrc/potato_util/constants/_regex.pyto export the new regex constants, ensuring they are available for import throughout the project.