Repository: pylint-dev/pylint

Issue:
When using camel case, private methods with two leading underscores raise invalid-name
### Bug description

```python
class MyClass:
    def __privateMethod(self):
        pass
```

### Configuration

```ini
[BASIC]
method-naming-style=camelCase
```

### Command used

```shell
pylint a.py
```

### Pylint output

```python
...
a.py:2:4: C0103: Method name "__privateMethod" doesn't conform to camelCase naming style (invalid-name)
...
```

### Expected behavior

I'd expect that the the name __privateMethod should be OK with the camelCase setting.

### Pylint version

```shell
pylint 3.3.3
astroid 3.3.8
Python 3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)]
```

### OS / Environment

_No response_

### Additional dependencies

```python

```


Discussion:

Patch:
diff --git a/doc/whatsnew/fragments/10189.bugfix b/doc/whatsnew/fragments/10189.bugfix
new file mode 100644
index 0000000000..4f5cf545de
--- /dev/null
+++ b/doc/whatsnew/fragments/10189.bugfix
@@ -0,0 +1,3 @@
+Fixed raising invalid-name when using camelCase for private methods with two leading underscores.
+
+Closes #10189
diff --git a/pylint/checkers/base/name_checker/naming_style.py b/pylint/checkers/base/name_checker/naming_style.py
index 0198ae7d1e..72f4dd8ed9 100644
--- a/pylint/checkers/base/name_checker/naming_style.py
+++ b/pylint/checkers/base/name_checker/naming_style.py
@@ -64,7 +64,7 @@ class CamelCaseStyle(NamingStyle):
     MOD_NAME_RGX = re.compile(r"[^\W\dA-Z][^\W_]*$")
     CONST_NAME_RGX = re.compile(r"([^\W\dA-Z][^\W_]*|__.*__)$")
     COMP_VAR_RGX = MOD_NAME_RGX
-    DEFAULT_NAME_RGX = re.compile(r"([^\W\dA-Z][^\W_]*|__[^\W\dA-Z_]\w+__)$")
+    DEFAULT_NAME_RGX = re.compile(r"(?:__)?([^\W\dA-Z][^\W_]*|__[^\W\dA-Z_]\w+__)$")
     CLASS_ATTRIBUTE_RGX = re.compile(r"([^\W\dA-Z][^\W_]*|__.*__)$")
 
 


Test patch:
diff --git a/tests/functional/n/namePresetCamelCase.py b/tests/functional/n/namePresetCamelCase.py
index e048ec4d8a..575b851c66 100644
--- a/tests/functional/n/namePresetCamelCase.py
+++ b/tests/functional/n/namePresetCamelCase.py
@@ -1,4 +1,4 @@
-# pylint: disable=missing-docstring,too-few-public-methods
+# pylint: disable=missing-docstring,too-few-public-methods,unused-private-member
 __version__ = "1.0"
 SOME_CONSTANT = 42  # [invalid-name]
 
@@ -18,6 +18,11 @@ def myPublicX(self):
     def __eq__(self, other):
         return isinstance(other, MyClass) and self.myPublicX == other.myPublicX
 
+    def __privateMethod(self):
+        pass
+
+    def _protectedMethod(self):
+        pass
 
 def say_hello():  # [invalid-name]
     pass
diff --git a/tests/functional/n/namePresetCamelCase.txt b/tests/functional/n/namePresetCamelCase.txt
index 900f7dceb9..ff2f17ae29 100644
--- a/tests/functional/n/namePresetCamelCase.txt
+++ b/tests/functional/n/namePresetCamelCase.txt
@@ -1,3 +1,3 @@
-invalid-name:3:0:3:13::"Constant name ""SOME_CONSTANT"" doesn't conform to camelCase naming style ('([^\\W\\dA-Z][^\\W_]*|__.*__)$' pattern)":HIGH
-invalid-name:10:0:10:13:MyClass:"Class name ""MyClass"" doesn't conform to camelCase naming style ('[^\\W\\dA-Z][^\\W_]*$' pattern)":HIGH
-invalid-name:22:0:22:13:say_hello:"Function name ""say_hello"" doesn't conform to camelCase naming style ('([^\\W\\dA-Z][^\\W_]*|__[^\\W\\dA-Z_]\\w+__)$' pattern)":HIGH
+invalid-name:3:0:3:13::"Constant name ""SOME_CONSTANT"" doesn't conform to camelCase naming style ('([^\\W\\dA-Z][^\\W_]*|__.*__)$' pattern)":HIGH
+invalid-name:10:0:10:13:MyClass:"Class name ""MyClass"" doesn't conform to camelCase naming style ('[^\\W\\dA-Z][^\\W_]*$' pattern)":HIGH
+invalid-name:27:0:27:13:say_hello:"Function name ""say_hello"" doesn't conform to camelCase naming style ('(?:__)?([^\\W\\dA-Z][^\\W_]*|__[^\\W\\dA-Z_]\\w+__)$' pattern)":HIGH