We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Incorrect type annotation on Generator.add_provider
* Faker version: 18.3.2
* OS: MacOS

The type annotation on `Generator.add_provider` is needlessly restrictive - the implementation clearly supports passing either a type or an instance, but the type annotation only allows instances:

```python
    # faker/generator.py
    def add_provider(self, provider: "BaseProvider") -> None:
        if isinstance(provider, type):
            provider = provider(self)
```


### Steps to reproduce

1. Write code that adds a provider class to a `Generator`
2. Run mypy

```python
class MyCustomProvider(BaseProvider):
    pass

fake = Factory.create("en_US")
fake.add_provider(MyCustomProvider)
```

### Expected behavior

`mypy` check should pass

### Actual behavior

`mypy` produces an error:

```
error: Argument 1 to "add_provider" of "Generator" has incompatible type "Type[MyCustomProvider]"; expected "BaseProvider"  [arg-type]
```

Incorrect type annotation on Generator.add_provider
* Faker version: 18.3.2
* OS: MacOS

The type annotation on `Generator.add_provider` is needlessly restrictive - the implementation clearly supports passing either a type or an instance, but the type annotation only allows instances:

```python
    # faker/generator.py
    def add_provider(self, provider: "BaseProvider") -> None:
        if isinstance(provider, type):
            provider = provider(self)
```


### Steps to reproduce

1. Write code that adds a provider class to a `Generator`
2. Run mypy

```python
class MyCustomProvider(BaseProvider):
    pass

fake = Factory.create("en_US")
fake.add_provider(MyCustomProvider)
```

### Expected behavior

`mypy` check should pass

### Actual behavior

`mypy` produces an error:

```
error: Argument 1 to "add_provider" of "Generator" has incompatible type "Type[MyCustomProvider]"; expected "BaseProvider"  [arg-type]
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `faker/generator.py`
Content:
```
1 import random as random_module
2 import re
3 
4 from typing import TYPE_CHECKING, Any, Callable, Dict, Hashable, List, Optional
5 
6 from .typing import SeedType
7 
8 if TYPE_CHECKING:
9     from .providers import BaseProvider
10 
11 _re_token = re.compile(r"\{\{\s*(\w+)(:\s*\w+?)?\s*\}\}")
12 random = random_module.Random()
13 mod_random = random  # compat with name released in 0.8
14 
15 
16 Sentinel = object()
17 
18 
19 class Generator:
20     __config: Dict[str, Dict[Hashable, Any]] = {
21         "arguments": {},
22     }
23 
24     _is_seeded = False
25     _global_seed = Sentinel
26 
27     def __init__(self, **config: Dict) -> None:
28         self.providers: List["BaseProvider"] = []
29         self.__config = dict(list(self.__config.items()) + list(config.items()))
30         self.__random = random
31 
32     def add_provider(self, provider: "BaseProvider") -> None:
33         if isinstance(provider, type):
34             provider = provider(self)
35 
36         self.providers.insert(0, provider)
37 
38         for method_name in dir(provider):
39             # skip 'private' method
40             if method_name.startswith("_"):
41                 continue
42 
43             faker_function = getattr(provider, method_name)
44 
45             if callable(faker_function):
46                 # add all faker method to generator
47                 self.set_formatter(method_name, faker_function)
48 
49     def provider(self, name: str) -> Optional["BaseProvider"]:
50         try:
51             lst = [p for p in self.get_providers() if hasattr(p, "__provider__") and p.__provider__ == name.lower()]
52             return lst[0]
53         except IndexError:
54             return None
55 
56     def get_providers(self) -> List["BaseProvider"]:
57         """Returns added providers."""
58         return self.providers
59 
60     @property
61     def random(self) -> random_module.Random:
62         return self.__random
63 
64     @random.setter
65     def random(self, value: random_module.Random) -> None:
66         self.__random = value
67 
68     def seed_instance(self, seed: Optional[SeedType] = None) -> "Generator":
69         """Calls random.seed"""
70         if self.__random == random:
71             # create per-instance random obj when first time seed_instance() is
72             # called
73             self.__random = random_module.Random()
74         self.__random.seed(seed)
75         self._is_seeded = True
76         return self
77 
78     @classmethod
79     def seed(cls, seed: Optional[SeedType] = None) -> None:
80         random.seed(seed)
81         cls._global_seed = seed
82         cls._is_seeded = True
83 
84     def format(self, formatter: str, *args: Any, **kwargs: Any) -> str:
85         """
86         This is a secure way to make a fake from another Provider.
87         """
88         return self.get_formatter(formatter)(*args, **kwargs)
89 
90     def get_formatter(self, formatter: str) -> Callable:
91         try:
92             return getattr(self, formatter)
93         except AttributeError:
94             if "locale" in self.__config:
95                 msg = f'Unknown formatter {formatter!r} with locale {self.__config["locale"]!r}'
96             else:
97                 raise AttributeError(f"Unknown formatter {formatter!r}")
98             raise AttributeError(msg)
99 
100     def set_formatter(self, name: str, method: Callable) -> None:
101         """
102         This method adds a provider method to generator.
103         Override this method to add some decoration or logging stuff.
104         """
105         setattr(self, name, method)
106 
107     def set_arguments(self, group: str, argument: str, value: Optional[Any] = None) -> None:
108         """
109         Creates an argument group, with an individual argument or a dictionary
110         of arguments. The argument groups is used to apply arguments to tokens,
111         when using the generator.parse() method. To further manage argument
112         groups, use get_arguments() and del_arguments() methods.
113 
114         generator.set_arguments('small', 'max_value', 10)
115         generator.set_arguments('small', {'min_value': 5, 'max_value': 10})
116         """
117         if group not in self.__config["arguments"]:
118             self.__config["arguments"][group] = {}
119 
120         if isinstance(argument, dict):
121             self.__config["arguments"][group] = argument
122         elif not isinstance(argument, str):
123             raise ValueError("Arguments must be either a string or dictionary")
124         else:
125             self.__config["arguments"][group][argument] = value
126 
127     def get_arguments(self, group: str, argument: Optional[str] = None) -> Any:
128         """
129         Get the value of an argument configured within a argument group, or
130         the entire group as a dictionary. Used in conjunction with the
131         set_arguments() method.
132 
133         generator.get_arguments('small', 'max_value')
134         generator.get_arguments('small')
135         """
136         if group in self.__config["arguments"] and argument:
137             result = self.__config["arguments"][group].get(argument)
138         else:
139             result = self.__config["arguments"].get(group)
140 
141         return result
142 
143     def del_arguments(self, group: str, argument: Optional[str] = None) -> Any:
144         """
145         Delete an argument from an argument group or the entire argument group.
146         Used in conjunction with the set_arguments() method.
147 
148         generator.del_arguments('small')
149         generator.del_arguments('small', 'max_value')
150         """
151         if group in self.__config["arguments"]:
152             if argument:
153                 result = self.__config["arguments"][group].pop(argument)
154             else:
155                 result = self.__config["arguments"].pop(group)
156         else:
157             result = None
158 
159         return result
160 
161     def parse(self, text: str) -> str:
162         """
163         Replaces tokens like '{{ tokenName }}' or '{{tokenName}}' in a string with
164         the result from the token method call. Arguments can be parsed by using an
165         argument group. For more information on the use of argument groups, please
166         refer to the set_arguments() method.
167 
168         Example:
169 
170         generator.set_arguments('red_rgb', {'hue': 'red', 'color_format': 'rgb'})
171         generator.set_arguments('small', 'max_value', 10)
172 
173         generator.parse('{{ color:red_rgb }} - {{ pyint:small }}')
174         """
175         return _re_token.sub(self.__format_token, text)
176 
177     def __format_token(self, matches):
178         formatter, argument_group = list(matches.groups())
179         argument_group = argument_group.lstrip(":").strip() if argument_group else ""
180 
181         if argument_group:
182             try:
183                 arguments = self.__config["arguments"][argument_group]
184             except KeyError:
185                 raise AttributeError(f"Unknown argument group {argument_group!r}")
186 
187             formatted = str(self.format(formatter, **arguments))
188         else:
189             formatted = str(self.format(formatter))
190 
191         return "".join(formatted)
192
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/faker/generator.py b/faker/generator.py
--- a/faker/generator.py
+++ b/faker/generator.py
@@ -1,7 +1,7 @@
 import random as random_module
 import re
 
-from typing import TYPE_CHECKING, Any, Callable, Dict, Hashable, List, Optional
+from typing import TYPE_CHECKING, Any, Callable, Dict, Hashable, List, Optional, Type, Union
 
 from .typing import SeedType
 
@@ -29,7 +29,7 @@
         self.__config = dict(list(self.__config.items()) + list(config.items()))
         self.__random = random
 
-    def add_provider(self, provider: "BaseProvider") -> None:
+    def add_provider(self, provider: Union["BaseProvider", Type["BaseProvider"]]) -> None:
         if isinstance(provider, type):
             provider = provider(self)

{"golden_diff": "diff --git a/faker/generator.py b/faker/generator.py\n--- a/faker/generator.py\n+++ b/faker/generator.py\n@@ -1,7 +1,7 @@\n import random as random_module\n import re\n \n-from typing import TYPE_CHECKING, Any, Callable, Dict, Hashable, List, Optional\n+from typing import TYPE_CHECKING, Any, Callable, Dict, Hashable, List, Optional, Type, Union\n \n from .typing import SeedType\n \n@@ -29,7 +29,7 @@\n         self.__config = dict(list(self.__config.items()) + list(config.items()))\n         self.__random = random\n \n-    def add_provider(self, provider: \"BaseProvider\") -> None:\n+    def add_provider(self, provider: Union[\"BaseProvider\", Type[\"BaseProvider\"]]) -> None:\n         if isinstance(provider, type):\n             provider = provider(self)\n", "issue": "Incorrect type annotation on Generator.add_provider\n* Faker version: 18.3.2\r\n* OS: MacOS\r\n\r\nThe type annotation on `Generator.add_provider` is needlessly restrictive - the implementation clearly supports passing either a type or an instance, but the type annotation only allows instances:\r\n\r\n```python\r\n    # faker/generator.py\r\n    def add_provider(self, provider: \"BaseProvider\") -> None:\r\n        if isinstance(provider, type):\r\n            provider = provider(self)\r\n```\r\n\r\n\r\n### Steps to reproduce\r\n\r\n1. Write code that adds a provider class to a `Generator`\r\n2. Run mypy\r\n\r\n```python\r\nclass MyCustomProvider(BaseProvider):\r\n    pass\r\n\r\nfake = Factory.create(\"en_US\")\r\nfake.add_provider(MyCustomProvider)\r\n```\r\n\r\n### Expected behavior\r\n\r\n`mypy` check should pass\r\n\r\n### Actual behavior\r\n\r\n`mypy` produces an error:\r\n\r\n```\r\nerror: Argument 1 to \"add_provider\" of \"Generator\" has incompatible type \"Type[MyCustomProvider]\"; expected \"BaseProvider\"  [arg-type]\r\n```\r\n\nIncorrect type annotation on Generator.add_provider\n* Faker version: 18.3.2\r\n* OS: MacOS\r\n\r\nThe type annotation on `Generator.add_provider` is needlessly restrictive - the implementation clearly supports passing either a type or an instance, but the type annotation only allows instances:\r\n\r\n```python\r\n    # faker/generator.py\r\n    def add_provider(self, provider: \"BaseProvider\") -> None:\r\n        if isinstance(provider, type):\r\n            provider = provider(self)\r\n```\r\n\r\n\r\n### Steps to reproduce\r\n\r\n1. Write code that adds a provider class to a `Generator`\r\n2. Run mypy\r\n\r\n```python\r\nclass MyCustomProvider(BaseProvider):\r\n    pass\r\n\r\nfake = Factory.create(\"en_US\")\r\nfake.add_provider(MyCustomProvider)\r\n```\r\n\r\n### Expected behavior\r\n\r\n`mypy` check should pass\r\n\r\n### Actual behavior\r\n\r\n`mypy` produces an error:\r\n\r\n```\r\nerror: Argument 1 to \"add_provider\" of \"Generator\" has incompatible type \"Type[MyCustomProvider]\"; expected \"BaseProvider\"  [arg-type]\r\n```\r\n\n", "before_files": [{"content": "import random as random_module\nimport re\n\nfrom typing import TYPE_CHECKING, Any, Callable, Dict, Hashable, List, Optional\n\nfrom .typing import SeedType\n\nif TYPE_CHECKING:\n    from .providers import BaseProvider\n\n_re_token = re.compile(r\"\\{\\{\\s*(\\w+)(:\\s*\\w+?)?\\s*\\}\\}\")\nrandom = random_module.Random()\nmod_random = random  # compat with name released in 0.8\n\n\nSentinel = object()\n\n\nclass Generator:\n    __config: Dict[str, Dict[Hashable, Any]] = {\n        \"arguments\": {},\n    }\n\n    _is_seeded = False\n    _global_seed = Sentinel\n\n    def __init__(self, **config: Dict) -> None:\n        self.providers: List[\"BaseProvider\"] = []\n        self.__config = dict(list(self.__config.items()) + list(config.items()))\n        self.__random = random\n\n    def add_provider(self, provider: \"BaseProvider\") -> None:\n        if isinstance(provider, type):\n            provider = provider(self)\n\n        self.providers.insert(0, provider)\n\n        for method_name in dir(provider):\n            # skip 'private' method\n            if method_name.startswith(\"_\"):\n                continue\n\n            faker_function = getattr(provider, method_name)\n\n            if callable(faker_function):\n                # add all faker method to generator\n                self.set_formatter(method_name, faker_function)\n\n    def provider(self, name: str) -> Optional[\"BaseProvider\"]:\n        try:\n            lst = [p for p in self.get_providers() if hasattr(p, \"__provider__\") and p.__provider__ == name.lower()]\n            return lst[0]\n        except IndexError:\n            return None\n\n    def get_providers(self) -> List[\"BaseProvider\"]:\n        \"\"\"Returns added providers.\"\"\"\n        return self.providers\n\n    @property\n    def random(self) -> random_module.Random:\n        return self.__random\n\n    @random.setter\n    def random(self, value: random_module.Random) -> None:\n        self.__random = value\n\n    def seed_instance(self, seed: Optional[SeedType] = None) -> \"Generator\":\n        \"\"\"Calls random.seed\"\"\"\n        if self.__random == random:\n            # create per-instance random obj when first time seed_instance() is\n            # called\n            self.__random = random_module.Random()\n        self.__random.seed(seed)\n        self._is_seeded = True\n        return self\n\n    @classmethod\n    def seed(cls, seed: Optional[SeedType] = None) -> None:\n        random.seed(seed)\n        cls._global_seed = seed\n        cls._is_seeded = True\n\n    def format(self, formatter: str, *args: Any, **kwargs: Any) -> str:\n        \"\"\"\n        This is a secure way to make a fake from another Provider.\n        \"\"\"\n        return self.get_formatter(formatter)(*args, **kwargs)\n\n    def get_formatter(self, formatter: str) -> Callable:\n        try:\n            return getattr(self, formatter)\n        except AttributeError:\n            if \"locale\" in self.__config:\n                msg = f'Unknown formatter {formatter!r} with locale {self.__config[\"locale\"]!r}'\n            else:\n                raise AttributeError(f\"Unknown formatter {formatter!r}\")\n            raise AttributeError(msg)\n\n    def set_formatter(self, name: str, method: Callable) -> None:\n        \"\"\"\n        This method adds a provider method to generator.\n        Override this method to add some decoration or logging stuff.\n        \"\"\"\n        setattr(self, name, method)\n\n    def set_arguments(self, group: str, argument: str, value: Optional[Any] = None) -> None:\n        \"\"\"\n        Creates an argument group, with an individual argument or a dictionary\n        of arguments. The argument groups is used to apply arguments to tokens,\n        when using the generator.parse() method. To further manage argument\n        groups, use get_arguments() and del_arguments() methods.\n\n        generator.set_arguments('small', 'max_value', 10)\n        generator.set_arguments('small', {'min_value': 5, 'max_value': 10})\n        \"\"\"\n        if group not in self.__config[\"arguments\"]:\n            self.__config[\"arguments\"][group] = {}\n\n        if isinstance(argument, dict):\n            self.__config[\"arguments\"][group] = argument\n        elif not isinstance(argument, str):\n            raise ValueError(\"Arguments must be either a string or dictionary\")\n        else:\n            self.__config[\"arguments\"][group][argument] = value\n\n    def get_arguments(self, group: str, argument: Optional[str] = None) -> Any:\n        \"\"\"\n        Get the value of an argument configured within a argument group, or\n        the entire group as a dictionary. Used in conjunction with the\n        set_arguments() method.\n\n        generator.get_arguments('small', 'max_value')\n        generator.get_arguments('small')\n        \"\"\"\n        if group in self.__config[\"arguments\"] and argument:\n            result = self.__config[\"arguments\"][group].get(argument)\n        else:\n            result = self.__config[\"arguments\"].get(group)\n\n        return result\n\n    def del_arguments(self, group: str, argument: Optional[str] = None) -> Any:\n        \"\"\"\n        Delete an argument from an argument group or the entire argument group.\n        Used in conjunction with the set_arguments() method.\n\n        generator.del_arguments('small')\n        generator.del_arguments('small', 'max_value')\n        \"\"\"\n        if group in self.__config[\"arguments\"]:\n            if argument:\n                result = self.__config[\"arguments\"][group].pop(argument)\n            else:\n                result = self.__config[\"arguments\"].pop(group)\n        else:\n            result = None\n\n        return result\n\n    def parse(self, text: str) -> str:\n        \"\"\"\n        Replaces tokens like '{{ tokenName }}' or '{{tokenName}}' in a string with\n        the result from the token method call. Arguments can be parsed by using an\n        argument group. For more information on the use of argument groups, please\n        refer to the set_arguments() method.\n\n        Example:\n\n        generator.set_arguments('red_rgb', {'hue': 'red', 'color_format': 'rgb'})\n        generator.set_arguments('small', 'max_value', 10)\n\n        generator.parse('{{ color:red_rgb }} - {{ pyint:small }}')\n        \"\"\"\n        return _re_token.sub(self.__format_token, text)\n\n    def __format_token(self, matches):\n        formatter, argument_group = list(matches.groups())\n        argument_group = argument_group.lstrip(\":\").strip() if argument_group else \"\"\n\n        if argument_group:\n            try:\n                arguments = self.__config[\"arguments\"][argument_group]\n            except KeyError:\n                raise AttributeError(f\"Unknown argument group {argument_group!r}\")\n\n            formatted = str(self.format(formatter, **arguments))\n        else:\n            formatted = str(self.format(formatter))\n\n        return \"\".join(formatted)\n", "path": "faker/generator.py"}], "after_files": [{"content": "import random as random_module\nimport re\n\nfrom typing import TYPE_CHECKING, Any, Callable, Dict, Hashable, List, Optional, Type, Union\n\nfrom .typing import SeedType\n\nif TYPE_CHECKING:\n    from .providers import BaseProvider\n\n_re_token = re.compile(r\"\\{\\{\\s*(\\w+)(:\\s*\\w+?)?\\s*\\}\\}\")\nrandom = random_module.Random()\nmod_random = random  # compat with name released in 0.8\n\n\nSentinel = object()\n\n\nclass Generator:\n    __config: Dict[str, Dict[Hashable, Any]] = {\n        \"arguments\": {},\n    }\n\n    _is_seeded = False\n    _global_seed = Sentinel\n\n    def __init__(self, **config: Dict) -> None:\n        self.providers: List[\"BaseProvider\"] = []\n        self.__config = dict(list(self.__config.items()) + list(config.items()))\n        self.__random = random\n\n    def add_provider(self, provider: Union[\"BaseProvider\", Type[\"BaseProvider\"]]) -> None:\n        if isinstance(provider, type):\n            provider = provider(self)\n\n        self.providers.insert(0, provider)\n\n        for method_name in dir(provider):\n            # skip 'private' method\n            if method_name.startswith(\"_\"):\n                continue\n\n            faker_function = getattr(provider, method_name)\n\n            if callable(faker_function):\n                # add all faker method to generator\n                self.set_formatter(method_name, faker_function)\n\n    def provider(self, name: str) -> Optional[\"BaseProvider\"]:\n        try:\n            lst = [p for p in self.get_providers() if hasattr(p, \"__provider__\") and p.__provider__ == name.lower()]\n            return lst[0]\n        except IndexError:\n            return None\n\n    def get_providers(self) -> List[\"BaseProvider\"]:\n        \"\"\"Returns added providers.\"\"\"\n        return self.providers\n\n    @property\n    def random(self) -> random_module.Random:\n        return self.__random\n\n    @random.setter\n    def random(self, value: random_module.Random) -> None:\n        self.__random = value\n\n    def seed_instance(self, seed: Optional[SeedType] = None) -> \"Generator\":\n        \"\"\"Calls random.seed\"\"\"\n        if self.__random == random:\n            # create per-instance random obj when first time seed_instance() is\n            # called\n            self.__random = random_module.Random()\n        self.__random.seed(seed)\n        self._is_seeded = True\n        return self\n\n    @classmethod\n    def seed(cls, seed: Optional[SeedType] = None) -> None:\n        random.seed(seed)\n        cls._global_seed = seed\n        cls._is_seeded = True\n\n    def format(self, formatter: str, *args: Any, **kwargs: Any) -> str:\n        \"\"\"\n        This is a secure way to make a fake from another Provider.\n        \"\"\"\n        return self.get_formatter(formatter)(*args, **kwargs)\n\n    def get_formatter(self, formatter: str) -> Callable:\n        try:\n            return getattr(self, formatter)\n        except AttributeError:\n            if \"locale\" in self.__config:\n                msg = f'Unknown formatter {formatter!r} with locale {self.__config[\"locale\"]!r}'\n            else:\n                raise AttributeError(f\"Unknown formatter {formatter!r}\")\n            raise AttributeError(msg)\n\n    def set_formatter(self, name: str, method: Callable) -> None:\n        \"\"\"\n        This method adds a provider method to generator.\n        Override this method to add some decoration or logging stuff.\n        \"\"\"\n        setattr(self, name, method)\n\n    def set_arguments(self, group: str, argument: str, value: Optional[Any] = None) -> None:\n        \"\"\"\n        Creates an argument group, with an individual argument or a dictionary\n        of arguments. The argument groups is used to apply arguments to tokens,\n        when using the generator.parse() method. To further manage argument\n        groups, use get_arguments() and del_arguments() methods.\n\n        generator.set_arguments('small', 'max_value', 10)\n        generator.set_arguments('small', {'min_value': 5, 'max_value': 10})\n        \"\"\"\n        if group not in self.__config[\"arguments\"]:\n            self.__config[\"arguments\"][group] = {}\n\n        if isinstance(argument, dict):\n            self.__config[\"arguments\"][group] = argument\n        elif not isinstance(argument, str):\n            raise ValueError(\"Arguments must be either a string or dictionary\")\n        else:\n            self.__config[\"arguments\"][group][argument] = value\n\n    def get_arguments(self, group: str, argument: Optional[str] = None) -> Any:\n        \"\"\"\n        Get the value of an argument configured within a argument group, or\n        the entire group as a dictionary. Used in conjunction with the\n        set_arguments() method.\n\n        generator.get_arguments('small', 'max_value')\n        generator.get_arguments('small')\n        \"\"\"\n        if group in self.__config[\"arguments\"] and argument:\n            result = self.__config[\"arguments\"][group].get(argument)\n        else:\n            result = self.__config[\"arguments\"].get(group)\n\n        return result\n\n    def del_arguments(self, group: str, argument: Optional[str] = None) -> Any:\n        \"\"\"\n        Delete an argument from an argument group or the entire argument group.\n        Used in conjunction with the set_arguments() method.\n\n        generator.del_arguments('small')\n        generator.del_arguments('small', 'max_value')\n        \"\"\"\n        if group in self.__config[\"arguments\"]:\n            if argument:\n                result = self.__config[\"arguments\"][group].pop(argument)\n            else:\n                result = self.__config[\"arguments\"].pop(group)\n        else:\n            result = None\n\n        return result\n\n    def parse(self, text: str) -> str:\n        \"\"\"\n        Replaces tokens like '{{ tokenName }}' or '{{tokenName}}' in a string with\n        the result from the token method call. Arguments can be parsed by using an\n        argument group. For more information on the use of argument groups, please\n        refer to the set_arguments() method.\n\n        Example:\n\n        generator.set_arguments('red_rgb', {'hue': 'red', 'color_format': 'rgb'})\n        generator.set_arguments('small', 'max_value', 10)\n\n        generator.parse('{{ color:red_rgb }} - {{ pyint:small }}')\n        \"\"\"\n        return _re_token.sub(self.__format_token, text)\n\n    def __format_token(self, matches):\n        formatter, argument_group = list(matches.groups())\n        argument_group = argument_group.lstrip(\":\").strip() if argument_group else \"\"\n\n        if argument_group:\n            try:\n                arguments = self.__config[\"arguments\"][argument_group]\n            except KeyError:\n                raise AttributeError(f\"Unknown argument group {argument_group!r}\")\n\n            formatted = str(self.format(formatter, **arguments))\n        else:\n            formatted = str(self.format(formatter))\n\n        return \"\".join(formatted)\n", "path": "faker/generator.py"}]}