mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	gh-116600: [Enum] fix global Flag repr (GH-116615)
* and fix global flag repr * Update Misc/NEWS.d/next/Library/2024-03-11-12-11-10.gh-issue-116600.FcNBy_.rst Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
This commit is contained in:
		
							parent
							
								
									3e45030076
								
							
						
					
					
						commit
						06e29a224f
					
				
					 3 changed files with 4 additions and 1 deletions
				
			
		|  | @ -1680,7 +1680,7 @@ def global_flag_repr(self): | |||
|     cls_name = self.__class__.__name__ | ||||
|     if self._name_ is None: | ||||
|         return "%s.%s(%r)" % (module, cls_name, self._value_) | ||||
|     if _is_single_bit(self): | ||||
|     if _is_single_bit(self._value_): | ||||
|         return '%s.%s' % (module, self._name_) | ||||
|     if self._boundary_ is not FlagBoundary.KEEP: | ||||
|         return '|'.join(['%s.%s' % (module, name) for name in self.name.split('|')]) | ||||
|  |  | |||
|  | @ -4063,6 +4063,8 @@ def test_global_repr_conform1(self): | |||
| 
 | ||||
|     @reraise_if_not_enum(NoName) | ||||
|     def test_global_enum_str(self): | ||||
|         self.assertEqual(repr(NoName.ONE), 'test_enum.ONE') | ||||
|         self.assertEqual(repr(NoName(0)), 'test_enum.NoName(0)') | ||||
|         self.assertEqual(str(NoName.ONE & NoName.TWO), 'NoName(0)') | ||||
|         self.assertEqual(str(NoName(0)), 'NoName(0)') | ||||
| 
 | ||||
|  |  | |||
|  | @ -0,0 +1 @@ | |||
| Fix :func:`repr` for global :class:`~enum.Flag` members. | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Ethan Furman
						Ethan Furman