mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	bpo-37163: Make the obj argument of dataclasses.replace() a positional-only. (GH-14390)
This commit is contained in:
		
							parent
							
								
									69150669f2
								
							
						
					
					
						commit
						2d88e63bfc
					
				
					 3 changed files with 3 additions and 2 deletions
				
			
		|  | @ -356,7 +356,7 @@ Module-level decorators, classes, and functions | ||||||
|          def add_one(self): |          def add_one(self): | ||||||
|              return self.x + 1 |              return self.x + 1 | ||||||
| 
 | 
 | ||||||
| .. function:: replace(instance, **changes) | .. function:: replace(instance, /, **changes) | ||||||
| 
 | 
 | ||||||
|    Creates a new object of the same type of ``instance``, replacing |    Creates a new object of the same type of ``instance``, replacing | ||||||
|    fields with values from ``changes``.  If ``instance`` is not a Data |    fields with values from ``changes``.  If ``instance`` is not a Data | ||||||
|  |  | ||||||
|  | @ -1206,7 +1206,7 @@ class C(Base): | ||||||
|                      unsafe_hash=unsafe_hash, frozen=frozen) |                      unsafe_hash=unsafe_hash, frozen=frozen) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def replace(obj, **changes): | def replace(obj, /, **changes): | ||||||
|     """Return a new object replacing specified fields with new values. |     """Return a new object replacing specified fields with new values. | ||||||
| 
 | 
 | ||||||
|     This is especially useful for frozen classes.  Example usage: |     This is especially useful for frozen classes.  Example usage: | ||||||
|  |  | ||||||
|  | @ -0,0 +1 @@ | ||||||
|  | The *obj* argument of :func:`dataclasses.replace` is positional-only now. | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Serhiy Storchaka
						Serhiy Storchaka