Fixes mypy attribute issue in io/parquet by adding a hasattr check
- [x] closes #45480, #44914
- [x] Passes tests in pytest
- [x] Ensure all linting tests pass, see [here](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit) for how to run them


Instead of checking for `io.BufferedWritter`, it might be better to use `io.FileIO` since it has `.name`:
https://github.com/python/typeshed/blob/3d28f0981f470a3e94d819705f8a95b77eaee56d/stdlib/io.pyi#L67

Probably would also make sense to change the if condition to `if isinstance(path_or_handle, io.FileIO) and isintance(path_or_handle.name, (str, bytes))` as `.name` could apparently also be an `int`. @Anirudhsekar96 great ping on green great ping on green The checks have completed running Thank you @Anirudhsekar96 