@@ -74,6 +74,11 @@ def pretty_helptext_list(values: list[str] | tuple[str, ...]) -> str:
74
74
date, date-time, email, ipv4, ipv6, regex, uuid
75
75
76
76
\b
77
+ For the "email" and "idn-email" formats, there are multiple modes which can be specified with
78
+ '--format-email':
79
+ default | only check that the string contains "@"
80
+ full | check the string against RFC 5321 (email) or RFC 6531 (idn-email)
81
+
77
82
For the "regex" format, there are multiple modes which can be specified with
78
83
'--format-regex':
79
84
default | check that the string is a valid ECMAScript regex
@@ -155,6 +160,16 @@ def pretty_helptext_list(values: list[str] | tuple[str, ...]) -> str:
155
160
default = RegexVariantName .default .value ,
156
161
type = click .Choice ([x .value for x in RegexVariantName ], case_sensitive = False ),
157
162
)
163
+ @click .option (
164
+ "--format-email" ,
165
+ help = (
166
+ "Set the mode of format validation for email addresses. "
167
+ "If `--disable-formats email` or `--disable-formats idn-email` is "
168
+ "used, this option has no effect on the disabled format."
169
+ ),
170
+ default = EmailVariantName .default .value ,
171
+ type = click .Choice ([x .value for x in EmailVariantName ], case_sensitive = False ),
172
+ )
158
173
@click .option (
159
174
"--default-filetype" ,
160
175
help = "A default filetype to assume when a file's type is not detected" ,
@@ -240,6 +255,7 @@ def main(
240
255
no_cache : bool ,
241
256
cache_filename : str | None ,
242
257
disable_formats : tuple [list [str ], ...],
258
+ format_email : Literal ["full" , "default" ],
243
259
format_regex : Literal ["python" , "default" ],
244
260
default_filetype : Literal ["json" , "yaml" , "toml" , "json5" ],
245
261
traceback_mode : Literal ["full" , "short" ],
@@ -267,6 +283,7 @@ def main(
267
283
else :
268
284
args .disable_formats = normalized_disable_formats
269
285
286
+ args .format_email = RegexVariantName (format_email )
270
287
args .format_regex = RegexVariantName (format_regex )
271
288
args .disable_cache = no_cache
272
289
args .default_filetype = default_filetype
0 commit comments