@@ -68,10 +68,10 @@ def pretty_helptext_list(values: list[str] | tuple[str, ...]) -> str:
6868 date, date-time, email, ipv4, ipv6, regex, uuid
6969
7070\b
71- For the "regex" format , there are multiple modes which can be specified with
72- '--format- regex':
73- default | check that the string is a valid ECMAScript regex
74- python | check that the string is a valid python regex
71+ For handling of regexes , there are multiple modes which can be specified with
72+ '--regex-variant ':
73+ default | use ECMAScript regex syntax (via regress)
74+ python | use python regex syntax
7575
7676\b
7777The '--builtin-schema' flag supports the following schema names:
@@ -138,11 +138,18 @@ def pretty_helptext_list(values: list[str] | tuple[str, ...]) -> str:
138138)
139139@click .option (
140140 "--format-regex" ,
141+ hidden = True ,
142+ help = "Legacy name for `--regex-variant`." ,
143+ default = None ,
144+ type = click .Choice ([x .value for x in RegexVariantName ], case_sensitive = False ),
145+ )
146+ @click .option (
147+ "--regex-variant" ,
141148 help = (
142- "Set the mode of format validation for regexes. "
143- "If `--disable-formats regex` is used, this option has no effect ."
149+ "Name of which regex dialect should be used for format checking "
150+ "and 'pattern' matching ."
144151 ),
145- default = RegexVariantName . default . value ,
152+ default = None ,
146153 type = click .Choice ([x .value for x in RegexVariantName ], case_sensitive = False ),
147154)
148155@click .option (
@@ -230,7 +237,8 @@ def main(
230237 no_cache : bool ,
231238 cache_filename : str | None ,
232239 disable_formats : tuple [list [str ], ...],
233- format_regex : t .Literal ["python" , "default" ],
240+ format_regex : t .Literal ["python" , "default" ] | None ,
241+ regex_variant : t .Literal ["python" , "default" ] | None ,
234242 default_filetype : t .Literal ["json" , "yaml" , "toml" , "json5" ],
235243 traceback_mode : t .Literal ["full" , "short" ],
236244 data_transform : t .Literal ["azure-pipelines" , "gitlab-ci" ] | None ,
@@ -243,6 +251,8 @@ def main(
243251) -> None :
244252 args = ParseResult ()
245253
254+ args .set_regex_variant (regex_variant , legacy_opt = format_regex )
255+
246256 args .set_schema (schemafile , builtin_schema , check_metaschema )
247257 args .set_validator (validator_class )
248258
@@ -257,7 +267,6 @@ def main(
257267 else :
258268 args .disable_formats = normalized_disable_formats
259269
260- args .format_regex = RegexVariantName (format_regex )
261270 args .disable_cache = no_cache
262271 args .default_filetype = default_filetype
263272 args .fill_defaults = fill_defaults
0 commit comments