Repository: pydantic/pydantic

Issue:
specifying default value in Field causes Pylance to expect an argument when calling the model constructor
# Bug

If you put the following snippet in VSCode and use Pylance (a common setup I assume), the below snippet will cause Pylance to complain `Argument missing for parameter value`.

Maybe it's a Pylance issue, maybe not.. I don't know enough, but it would be super awesome if there's some switch you can flip to support this :)

```python
from pydantic import BaseModel, Field, constr

class MyModel(BaseModel):
    value: str = Field('default_value', type=constr, min_length=1, max_length=200)

if __name__ == "__main__":
    a = MyModel()
    print(a)

```


Discussion:

Resolving patch:
diff --git a/pydantic/networks.py b/pydantic/networks.py
--- a/pydantic/networks.py
+++ b/pydantic/networks.py
@@ -706,32 +706,34 @@ def validate(cls, value: NetworkType) -> Union[IPv4Network, IPv6Network]:
 
 def validate_email(value: Union[str]) -> Tuple[str, str]:
     """
-    Brutally simple email address validation. Note unlike most email address validation
+    Email address validation using https://pypi.org/project/email-validator/
+    Notes:
     * raw ip address (literal) domain parts are not allowed.
     * "John Doe <local_part@domain.com>" style "pretty" email addresses are processed
-    * the local part check is extremely basic. This raises the possibility of unicode spoofing, but no better
-        solution is really possible.
     * spaces are striped from the beginning and end of addresses but no error is raised
-
-    See RFC 5322 but treat it with suspicion, there seems to exist no universally acknowledged test for a valid email!
     """
     if email_validator is None:
         import_email_validator()
-
     m = pretty_email_regex.fullmatch(value)
-    name: Optional[str] = None
+    name: Union[str, None] = None
     if m:
         name, value = m.groups()
-
     email = value.strip()
-
     try:
-        email_validator.validate_email(email, check_deliverability=False)
+        parts = email_validator.validate_email(email, check_deliverability=False)
     except email_validator.EmailNotValidError as e:
-        raise errors.EmailError() from e
-
-    at_index = email.index('@')
-    local_part = email[:at_index]  # RFC 5321, local part must be case-sensitive.
-    global_part = email[at_index:].lower()
-
-    return name or local_part, local_part + global_part
+        raise errors.EmailError from e
+
+    if hasattr(parts, 'normalized'):
+        # email-validator >= 2
+        email = parts.normalized
+        assert email is not None
+        name = name or parts.local_part
+        return name, email
+    else:
+        # email-validator >1, <2
+        at_index = email.index('@')
+        local_part = email[:at_index]  # RFC 5321, local part must be case-sensitive.
+        global_part = email[at_index:].lower()
+
+        return name or local_part, local_part + global_part


Test patch:
diff --git a/tests/requirements-testing.txt b/tests/requirements-testing.txt
--- a/tests/requirements-testing.txt
+++ b/tests/requirements-testing.txt
@@ -1,7 +1,7 @@
 coverage==6.4.4
 hypothesis==6.54.4
 # pin importlib-metadata as upper versions need typing-extensions to work if on Python < 3.8
-importlib-metadata==3.1.0;python_version<"3.8"
+importlib-metadata==3.6.0;python_version<"3.8"
 mypy==0.971
 pytest==7.2.1
 pytest-cov==4.0.0
@@ -9,3 +9,6 @@ pytest-mock==3.10.0
 pytest-sugar==0.9.6
 # pin typing-extensions to minimum requirement - see #4885
 typing-extensions==4.2.0
+# used in FastAPI tests, pin to avoid warnings in newer version
+# that FastAPI needs to fix
+Flask==2.2.3