avoid a warning by PyTypeChecker
NDFrame.to_csv(str) got a warning by PyTypeChecker, "Expected type 'None', got 'str' instead"
use typing.Union to combine type "FilePathOrBuffer[AnyStr]" and "None", instead of " | " can avoid it.
![image](https://user-images.githubusercontent.com/24448028/141879473-56355ca2-60de-4405-94a3-fdc3013cf5a7.png)

- [ ] closes #xxxx
- [ ] tests added / passed
- [ ] 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
- [ ] whatsnew entry

Hello @foreverseer! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:



There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: 

##### Comment last updated at 2021-11-16 01:40:18 UTC If `PyTypeChecker` cannot handle `|`, then it might be worth to open a bug at `PyTypeChecker`? Pandas is not yet a py.typed library, can you double-check that `PyTypeChecker` is getting the type annotations from pandas (or a third-party stub file)?

Do you mind testing whether `PyTypeChecker` still has the issue on master? You are welcome to also test `PyTypeChecker` with #43951. > If `PyTypeChecker` cannot handle `|`, then it might be worth to open a bug at `PyTypeChecker`? Pandas is not yet a py.typed library, can you double-check that `PyTypeChecker` is getting the type annotations from pandas (or a third-party stub file)?
> 
> Do you mind testing whether `PyTypeChecker` still has the issue on master? You are welcome to also test `PyTypeChecker` with #43951.

pytypechecker is a function of pycharm
i mean not use Union to combine two type will cause a warning of pycharm 
![image](https://user-images.githubusercontent.com/24448028/141881148-ffd88aed-0dc9-4a58-9cfb-8ac01a742889.png)
↑this is pycharm's warning
 `pandas/core/generic.py` uses the python 3.10+ syntax `|` (equivalent to `typing.Union`) and also has `from __future__ import annotations` which enables this syntax for older versions of python.

I recomend opening a bug with pycharm (after checking that pycharm is using the tpye annotations shipped with pandas itself - most likely it uses 3rd-party type stubs). Agreed, pandas uses `|` instead of `Union` consistently in the code base so it appears that this is more of an upstream issue. Closing.