Uploaded image for project: 'Couchbase Python Client Library'
  1. Couchbase Python Client Library
  2. PYCBC-801

Reflect optional nature of parameters in OptionBlock constructors

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.0.0-rc
    • None
    • None
    • 1
    • SDK9: Coll/Txn/Doc chipping

    Description

      Optional parameters need to be marked as such by adding a default, if they are to be explicitly named for the purposes of discovery.

      Attachments

        For Gerrit Dashboard: PYCBC-801
        # Subject Branch Project Status CR V

        Activity

          Ellis.Breen Ellis Breen added a comment - - edited

          For example:

          class ReplaceOptions(DurabilityOptionBlock):
              @overload
              def __init__(self,
                           timeout,       # type: timedelta
                           durability,    # type: DurabilityType
                           cas            # type: int
                           ):
                  pass
           
              def __init__(self,
                           **kwargs
                          ):
                  if 'cas' not in kwargs:
                      kwargs['cas'] = 0
                  super(ReplaceOptions, self).__init__(**kwargs)
          
          

          yields a warning in PyCharm as follows:

          Changing the code to this:

          class ReplaceOptions(DurabilityOptionBlock):
              @overload
              def __init__(self,
                           timeout=None,       # type: timedelta
                           durability=None,    # type: DurabilityType
                           cas=0            # type: int
                           ):
                  pass
           
              def __init__(self,
                           **kwargs
                          ):
                  super(ReplaceOptions, self).__init__(**kwargs)
          
          

          yields no warning:

          Ellis.Breen Ellis Breen added a comment - - edited For example: class ReplaceOptions(DurabilityOptionBlock): @overload def __init__( self , timeout, # type: timedelta durability, # type: DurabilityType cas # type: int ): pass   def __init__( self , * * kwargs ): if 'cas' not in kwargs: kwargs[ 'cas' ] = 0 super (ReplaceOptions, self ).__init__( * * kwargs) yields a warning in PyCharm as follows: Changing the code to this: class ReplaceOptions(DurabilityOptionBlock): @overload def __init__( self , timeout = None , # type: timedelta durability = None , # type: DurabilityType cas = 0 # type: int ): pass   def __init__( self , * * kwargs ): super (ReplaceOptions, self ).__init__( * * kwargs) yields no warning:

          People

            Ellis.Breen Ellis Breen
            Ellis.Breen Ellis Breen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty