Fix incorrect deprecation warnings on defaults (#348)
This change ensures that deprecation warnings are only raised when either a deprecated field is explicitly set or a deprecated message is initialised. Resolves: #347
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							9c1bf25304
						
					
				
				
					commit
					69f4192341
				
			| @@ -63,7 +63,7 @@ class {{ message.py_name }}(betterproto.Message): | ||||
|         {% endif %} | ||||
|         super().__post_init__() | ||||
|         {% for field in message.deprecated_fields %} | ||||
|         if self.{{ field }}: | ||||
|         if self.is_set("{{ field }}"): | ||||
|             warnings.warn("{{ message.py_name }}.{{ field }} is deprecated", DeprecationWarning) | ||||
|         {% endfor %} | ||||
|     {%  endif %} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user