mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	bpo-42385: [Enum] add _generate_next_value_ to StrEnum (GH-23735)
				
					
				
			The default for auto() is to return an integer, which doesn't work for `StrEnum`. The new `_generate_next_value_` for `StrEnum` returns the member name, lower cased.
This commit is contained in:
		
							parent
							
								
									9fc571359a
								
							
						
					
					
						commit
						efb13be72c
					
				
					 4 changed files with 17 additions and 2 deletions
				
			
		|  | @ -826,6 +826,12 @@ def __new__(cls, *values): | |||
| 
 | ||||
|     __str__ = str.__str__ | ||||
| 
 | ||||
|     def _generate_next_value_(name, start, count, last_values): | ||||
|         """ | ||||
|         Return the lower-cased version of the member name. | ||||
|         """ | ||||
|         return name.lower() | ||||
| 
 | ||||
| 
 | ||||
| def _reduce_ex_by_name(self, proto): | ||||
|     return self.name | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Ethan Furman
						Ethan Furman