support keyword substitutions in query() variants

Summary:
    - added **kwparameters next to *parameters everywhere
    - pulled out _ensure_encoded function to use again
    - removed extraneous checks for None - None cant be produced by
      *args / **kwargs type arguments
    - removed extraneous checks for ()/{} - empty substitution is a
      no-op and doesn't need a special case