Repository: pydantic/pydantic

Issue:
`BaseSettings`-specific configuration cannot be passed to class as keyword arguments
### Checks

* [x] I added a descriptive title to this issue
* [x] I have searched (google, github) for similar issues and couldn't find anything
* [x] I have read and followed [the docs](https://pydantic-docs.helpmanual.io/) and still think this is a bug

<!-- Sorry to sound so draconian, but every second saved replying to issues is time spend improving pydantic :-) -->

# Bug

Output of `python -c "import pydantic.utils; print(pydantic.utils.version_info())"`:
```
             pydantic version: 1.8.1
            pydantic compiled: False
                 install path: [...]/lib/python3.9/site-packages/pydantic
               python version: 3.9.2 (default, Feb 21 2021, 06:38:26)  [Clang 7.1.0 (tags/RELEASE_710/final)]
                     platform: macOS-10.14.6-x86_64-i386-64bit
     optional deps. installed: ['typing-extensions']
```
<!-- or if you're using pydantic prior to v1.3, manually include: OS, python version and pydantic version -->

<!-- Please read the [docs](https://pydantic-docs.helpmanual.io/) and search through issues to
confirm your bug hasn't already been reported. -->

<!-- Where possible please include a self-contained code snippet describing your bug: -->

The `BaseModel` metaclass ignores configuration settings specific to `BaseSettings` when these are passed as keyword arguments during class creation.  They are passed on to `ABCMeta` which does not accept keyword arguments:

```py
import pydantic

class Foo(pydantic.BaseSettings, env_prefix='BAR_'):
    pass

```
Output:

```
Traceback (most recent call last):
  File "[...]/foo.py", line 3, in <module>
    class Foo(pydantic.BaseSettings, env_prefix='BAR_'):
  File "[...]/lib/python3.9/site-packages/pydantic/main.py", line 361, in __new__
    cls = super().__new__(mcs, name, bases, new_namespace, **kwargs)
  File "/nix/store/cdifcrgj5phbvspzs02yglz35qql4i1x-python3-3.9.2/lib/python3.9/abc.py", line 85, in __new__
    cls = super().__new__(mcls, name, bases, namespace, **kwargs)
TypeError: Foo.__init_subclass__() takes no keyword arguments
```


Comments:

Patch:
diff --git a/pydantic/main.py b/pydantic/main.py
--- a/pydantic/main.py
+++ b/pydantic/main.py
@@ -248,7 +248,12 @@ def __new__(mcs, name, bases, namespace, **kwargs):  # noqa C901
                 class_vars.update(base.__class_vars__)
                 hash_func = base.__hash__
 
-        config_kwargs = {key: kwargs.pop(key) for key in kwargs.keys() & BaseConfig.__dict__.keys()}
+        allowed_config_kwargs: SetStr = {
+            key
+            for key in dir(config)
+            if not (key.startswith('__') and key.endswith('__'))  # skip dunder methods and attributes
+        }
+        config_kwargs = {key: kwargs.pop(key) for key in kwargs.keys() & allowed_config_kwargs}
         config_from_namespace = namespace.get('Config')
         if config_kwargs and config_from_namespace:
             raise TypeError('Specifying config in two places is ambiguous, use either Config attribute or class kwargs')


Test patch:
diff --git a/tests/test_main.py b/tests/test_main.py
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -7,6 +7,7 @@
 import pytest
 
 from pydantic import (
+    BaseConfig,
     BaseModel,
     ConfigError,
     Extra,
@@ -1734,3 +1735,14 @@ class Model(BaseModel, extra='allow'):
 
             class Config:
                 extra = 'forbid'
+
+
+def test_class_kwargs_custom_config():
+    class Base(BaseModel):
+        class Config(BaseConfig):
+            some_config = 'value'
+
+    class Model(Base, some_config='new_value'):
+        a: int
+
+    assert Model.__config__.some_config == 'new_value'