izveigor commented on code in PR #1759:
URL: https://github.com/apache/avro/pull/1759#discussion_r919851566
##########
lang/py/avro/schema.py:
##########
@@ -570,7 +570,12 @@ def __init__(
raise avro.errors.InvalidName("An enum symbol must be a
valid schema name.")
if len(set(symbols)) < len(symbols):
- raise avro.errors.AvroException(f"Duplicate symbol: {symbols}")
+ duplicate_symbols = {symbol for symbol in symbols if
symbols.count(symbol) > 1}
+
+ if len(duplicate_symbols) == 1:
Review Comment:
Hello, @clesaec!
I do not really understand what you want to say. if we have 0 duplicates
symbols, a length of set will less than a length of list and an error will not
raise. if we have 1 duplicate symbol, the application shows the list with only
one symbol. If we have more than 1 duplicate symbol, the application shows the
list of duplicates symbols.
The message for 1 duplicate symbol differs from the message for more 1
duplicates symbols only the grammar of the language.
If you worry about format of output (list), then many libraries use this
format both for one symbol and for many symbols. For example, marshmallow:
https://github.com/marshmallow-code/marshmallow/blob/dev/src/marshmallow/schema.py#L1009-L1018
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]