Repository: unionai-oss/pandera

Issue:
`mypy` breaks when using `Config`
**Describe the bug**
When running `mypy` 1.1.1 on the following simple class, it breaks with
```bash
/tmp/test.py:3: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.1.1
/tmp/test.py:3: : note: use --pdb to drop into pdb
Traceback (most recent call last):
  File "mypy/semanal.py", line 6261, in accept
  File "mypy/nodes.py", line 1123, in accept
  File "mypy/semanal.py", line 1561, in visit_class_def
  File "mypy/semanal.py", line 1641, in analyze_class
  File "mypy/semanal.py", line 1668, in analyze_class_body_common
  File "mypy/semanal.py", line 1751, in apply_class_plugin_hooks
  File "/usr/local/lib/python3.10/site-packages/pandera/mypy.py", line 93, in _pandera_model_class_maker_callback
    transformer.transform()
  File "/usr/local/lib/python3.10/site-packages/pandera/mypy.py", line 125, in transform
    self.erase_field_type_arg()
  File "/usr/local/lib/python3.10/site-packages/pandera/mypy.py", line 140, in erase_field_type_arg
    type_ = def_.type
AttributeError: 'ClassDef' object has no attribute 'type'

```

- [X] I have checked that this issue has not already been reported.
- [X] I have confirmed this bug exists on the latest version of pandera.
- [ ] (optional) I have confirmed this bug exists on the master branch of pandera.

#### Code Sample, a copy-pastable example
`test.py`
```python
import pandera

class Model(pandera.DataFrameModel):
    a: pandera.typing.Series[int]

    class Config:
        pass
```
`pyproject.toml`
```toml
[tool.mypy]
plugins = ["pandera.mypy"]
```

To reproduce, here is the Dockerfile
```docker
FROM python:3.10-slim-buster

RUN pip install mypy pandera[mypy]==0.14.4 
WORKDIR /tmp

RUN echo '[tool.mypy]\nplugins = ["pandera.mypy"]' > pyproject.toml 
RUN echo 'import pandera\n\nclass Model(pandera.DataFrameModel):\n\ta: pandera.typing.Series[int]\n\n\tclass Config:\n\t\tpass' > test.py 

CMD ["mypy", "--show-traceback", "/tmp/test.py"]
```

#### Expected behavior
`mypy` not breaking



Discussion:

Resolving patch:
diff --git a/pandera/engines/pandas_engine.py b/pandera/engines/pandas_engine.py
--- a/pandera/engines/pandas_engine.py
+++ b/pandera/engines/pandas_engine.py
@@ -695,7 +695,7 @@ def check(
                 ["<class 'str'>", "<class 'numpy.str_'>"]
             )
         else:
-            is_python_string = data_container.map(lambda x: isinstance(x, str))
+            is_python_string = data_container.map(lambda x: isinstance(x, str))  # type: ignore[operator]
         return is_python_string | data_container.isna()
 
 
diff --git a/pandera/mypy.py b/pandera/mypy.py
--- a/pandera/mypy.py
+++ b/pandera/mypy.py
@@ -137,6 +137,8 @@ class Schema(BaseSchema):
             x: pa.typing.Series[str]  # mypy assignment error, cannot override types
         """
         for def_ in self.ctx.cls.defs.body:
+            if not hasattr(def_, "type"):
+                continue
             type_ = def_.type
             if get_typename(def_.type) in FIELD_GENERICS_FULLNAMES:
                 type_.args = ()  # erase generic type arg


Test patch: