astahlman commented on a change in pull request #4974: [AIRFLOW-4057] Fix bug 
in stat name validation
URL: https://github.com/apache/airflow/pull/4974#discussion_r268920074
 
 

 ##########
 File path: docs/plugins.rst
 ##########
 @@ -212,7 +212,7 @@ definitions in Airflow.
         flask_blueprints = [bp]
         appbuilder_views = [v_appbuilder_package]
         appbuilder_menu_items = [appbuilder_mitem]
-        stat_name_handler = stat_name_dummy_handler
+        stat_name_handler = staticmethod(stat_name_dummy_handler)
 
 Review comment:
   Without this, assigning the function in this way binds it to the 
AirflowPlugin class. Illustration of the difference (on Python2):
   
   ```
   >>> def x(arg_that_should_be_str):
   ...   return arg_that_should_be_str
   ...
   >>> class Foo:
   ...   x = x
   ...
   >>> x_impl = Foo.x
   >>> x_impl("a string")
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
   TypeError: unbound method x() must be called with Foo instance as first 
argument (got str instance instead)
   >>>
   >>> class Foo:
   ...   x = staticmethod(x)
   ...
   >>> x_impl = Foo.x
   >>> x_impl("a string")
   'a string'
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to