Flaherty attended Harvard-Westlake School in Los Angeles, California, with Ethan Katz as his pitching coach. He pitched and played shortstop and third base as a member of the varsity baseball team for all four of his years at Harvard-Westlake. He was a sophomore when two of his high school teammates and fellow pitchers, Max Fried and Lucas Giolito, were both drafted in the first round of the 2012 MLB draft. In 2013, as a junior, Flaherty pitched a 13–0 record with a 0.63 ERA, striking out 112 batters in 89 innings while only walking 10. During his senior season, Harvard-Westlake was the consensus #1 team in the nation in the MaxPreps "XCellent 50" for much of the beginning of the season, before dropping out of the rankings altogether. On April 29, 2014, Flaherty pitched a complete game, 2–1 victory over Bishop Alemany High School to bring a two-year win–loss record to 20–0. In his last two seasons, his record was 23–0 overall. He finished the 2014 regular season with an 0.63 ERA and a 10–0 record on his way to being named Southern Section Division I Player of the Year along with the Los Angeles Times Player of the Year. He pitched 78 innings, struck out 125 batters while giving up just 32 hits and 12 bases on balls. In the first game of the playoffs – which was also the last game of his high school career – he threw a no-hitter against Riverside North. He was subsequently named the 2014 Gatorade Player of the Year in baseball for the state of California. The Los Angeles Times selected him as their baseball player of the year. In his four years on the mound, his record was 35–3.
Although Flaherty signed a letter of intent to attend the University of North Carolina, he began his professional career after the Cardinals drafted him in the first round with the 34th overall selection of the 2014 MLB draft. It was a compensatory pick that the Cardinals gained when Carlos Beltrán signed with the New York Yankees as a free agent. Flaherty signed with the Cardinals on June 17 for a $2 million bonus and began his minor league career with the Cardinals of the Gulf Coast League, where he posted a 1.59 ERA in 22.2 innings pitched. In 2015 he played for the Peoria Chiefs where he was 9-3 with a 2.84 ERA in 18 starts. Prior to the 2016 season, Baseball America ranked him as the third-best prospect in the Cardinals' system. He spent the season with the Palm Beach Cardinals. In their updated 2016 mid-season ranking, Baseball America rated Flaherty in the top-100 for the first time, at 88th. In 24 games at Palm Beach, Flaherty was 5-9 with a 3.56 ERA. Flaherty began the 2017 season with the Springfield Cardinals, and after posting a 7–2 record with a 1.42 ERA in ten starts, he was promoted to the Memphis Redbirds, where he was 7-2 with a 2.74 ERA in 15 starts. Combined, Flaherty struck out 147 and walked 35 in 148 innings.
St. Louis Cardinals (2017–present)
2017
On September 1, 2017, Flaherty was promoted to MLB to make his MLB debut against the San Francisco Giants. He pitched four innings, gave up five runs, and struck out six while not receiving a decision in an eventual 11–6 win. He struck out the first batter he faced, Denard Span. Flaherty finished the season 0–2 with a 6.33 ERA in 21.1 innings pitched. After the season, the Cardinals named Flaherty their 2017 Minor League Pitcher of the Year.
2018
On March 25, 2018, the Cardinals announced that Flaherty had made the Opening Day roster in place of the injured Adam Wainwright. He was optioned back to Memphis on April 4 once Wainwright was activated. He was recalled and optioned back once more before taking Wainwright's spot in the rotation in May when he was placed on the 60-day disabled list. Flaherty earned his first MLB win on May 20, 2018. Throwing 120 pitches, he gave up one earned run, struck out 13, walked one, and gave up only two hits in a 5–1 win over the Philadelphia Phillies at Busch Stadium. Flaherty finished his 2018 rookie year with an 8-9 record and a 3.34 ERA in 28 starts, striking out 182 batters in 151 innings pitched.
2019
Upon the Cardinals signing Matt Wieters, Flaherty switched his uniform number from 32 to 22 to accommodate the Wieters signing. Flaherty entered the second half of the season with an ERA of 4.64. Following the All-Star break, he yielded a 0.91 ERA, the third-lowest in major league history, behind only Bob Gibson and Jake Arrieta. Flaherty was named the National League Pitcher of the Month for August after going 5-1 with a 0.71 ERA, and he again won the award in September with a 0.82 ERA over 44 innings. He ended the 2019 regular season with an 11-8 record and a 2.75 ERA over 33 starts, striking out 231 over 196 innings. He became the third-youngest pitcher in baseball history to strike out at least 230 and walk 55 or fewer with a 2.75 ERA or lower. Following the season, he was nominated for his first ever Gold Glove and finished fourth in National League Cy Young Award voting.
Personal life
Flaherty was adopted by Eileen Flaherty when he was three weeks old. Flaherty is a Christian.