mirror of
				https://github.com/searxng/searxng.git
				synced 2025-11-04 03:27:06 -05:00 
			
		
		
		
	[fix] !weather crashes - cls.TURN 'member_descriptor' isn't a float (#5309)
The class method ``Compass.point`` is converted into an instance method to circumvent the problem described in [1] (without understanding the cause). [1] https://github.com/searxng/searxng/issues/5304#issuecomment-3394140820 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
		
							parent
							
								
									5492de15bb
								
							
						
					
					
						commit
						fc7d8b8be2
					
				@ -506,15 +506,14 @@ class Compass(msgspec.Struct):
 | 
				
			|||||||
            return self.val
 | 
					            return self.val
 | 
				
			||||||
        raise ValueError(f"unknown unit: {unit}")
 | 
					        raise ValueError(f"unknown unit: {unit}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @classmethod
 | 
					    def point(self, azimuth: float | int) -> CompassPoint:
 | 
				
			||||||
    def point(cls, azimuth: float | int) -> CompassPoint:
 | 
					 | 
				
			||||||
        """Returns the compass point to an azimuth value."""
 | 
					        """Returns the compass point to an azimuth value."""
 | 
				
			||||||
        azimuth = azimuth % cls.TURN
 | 
					        azimuth = azimuth % self.TURN
 | 
				
			||||||
        # The angle sector of a compass point starts 1/2 sector range before
 | 
					        # The angle sector of a compass point starts 1/2 sector range before
 | 
				
			||||||
        # and after compass point (example: "N" goes from -11.25° to +11.25°)
 | 
					        # and after compass point (example: "N" goes from -11.25° to +11.25°)
 | 
				
			||||||
        azimuth = azimuth - cls.RANGE / 2
 | 
					        azimuth = azimuth - self.RANGE / 2
 | 
				
			||||||
        idx = int(azimuth // cls.RANGE)
 | 
					        idx = int(azimuth // self.RANGE)
 | 
				
			||||||
        return cls.POINTS[idx]
 | 
					        return self.POINTS[idx]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def l10n(
 | 
					    def l10n(
 | 
				
			||||||
        self,
 | 
					        self,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user