[source code] why do many (not all) transformer classes have their docstring starting with r###
Why do many (not all) transformer classes have their docstring starting withr###grep -r -A 2 'class ' src/transformershere is just a sample of both:src/transformers/modeling_tf_xlnet.py:# class TFXLNetForQuestionAnswering(TFXLNetPreTrainedModel):
src/transformers/modeling_tf_xlnet.py-#     r"""
src/transformers/tokenization_distilbert.py:class DistilBertTokenizer(BertTokenizer):
src/transformers/tokenization_distilbert.py-    r"""
src/transformers/tokenization_gpt2.py:class GPT2TokenizerFast(PreTrainedTokenizerFast):
src/transformers/tokenization_gpt2.py-    """
src/transformers/tokenization_auto.py:class AutoTokenizer:
src/transformers/tokenization_auto.py-    r""":class:`~transformers.AutoTokenizer` is a generic tokenizer classIs there a special purpose for using a regex string? There doesn’t seem to be any pattern - it appears in some, but not the others classes’ docstring.Thank you.
2020-08-21T21:16:11Z
It’s r for raw, not regex. Not sure why they’re used exactly, it maybe to make sure some sphinx stuff doesn’t get interpreted weirdly. I know I added r in the new docstrings I created.
2020-08-21T23:17:06Z
Thank you for the explanation,@sgugger!So, when creating new classes you’re suggesting to user###, correct?In my experience most of the timeris used as a pattern in regex - that’s what I meant by a “regex string”. So I assumed it to be a regex thingI understand this could be needed elsewhere when \ are to be treated literally. So, “raw” does make more sense. Thank you for this,@sgugger!
2020-08-24T11:22:05Z
Yes I think r""" is a good default to have in mind.