MI185 in 1997 proved a clinically depressed cockpit crew member on duty is extremely risky (NTSB investigation). Fortunately this is an extremely rare event; but as this recent occurence has shown it can still happen if proper safeguards are not enforced.
Statistics on the incidence of depression suggest that there are hundreds, if not thousands, of cockpit crew with clinical depression who fly every day. The idea that this is "extremely risky" is not supported by the evidence.
What would make flying safer would be if those hundreds, or thousands, of depressed cockpit crew could safely seek treatment for their illness.