When “Crazy Ex-Girlfriend” returned for its third season earlier in October, it gave viewers a gift: a hilarious, 1980s-style musical number featuring the show’s four main female characters, Rebecca (Rachel Bloom), Paula (Donna Lynne Champlin), Valencia (Gabrielle Ruiz) and Heather (Vella Lovell) drinking a lot of rosé and venting about the opposite sex. “Let’s not distinguish between them at all / Let’s just drink a lot more alcohol / And then high five each other / As we make a bunch of blanket statements / Let’s generalize about men!” Not that it wouldn’t have been a delight to have “Crazy Ex-Girlfriend” back under any circumstances, but the series returned as the sexual harassment and assault scandal surrounding super-producer Harvey Weinstein was kicking off, prompting a wider discussion about misogyny.

In a three-minute clip, the song, “Let’s Generalize About Men,” crystallized why “Crazy Ex-Girlfriend” has felt so vital and revitalizing to me. At a moment when adhering to the idea that sexual harassment is bad or that the president shouldn’t feud with Gold Star widows can make one feel naive to the point of insanity, “Crazy Ex-Girlfriend” is a weird, cathartic space where women can indulge their worst impulses but the moral lines are still clear. Rebecca, the main character in “Crazy Ex-Girlfriend,” may be dangerously unstable, but somehow, the world she inhabits makes more sense to me right now than the one I’m stuck in.

To back up, “Crazy Ex-Girlfriend,” a musical dramedy which premiered in 2015 in the heat of the presidential primary season, follows Rebecca after she turns down a promotion at her law firm and upends her life in New York to move to West Covina, Calif., the home of Josh Chan (Vincent Rodriguez III), who was briefly her boyfriend at summer camp a decade before. Josh has no real interest in Rebecca — in fact, he’s in a long-standing if stagnant relationship with Valencia. But the power of Rebecca’s compulsive energy and oddly winning personality gradually win over everyone around her, from Paula, the paralegal at her new law firm; to Heather, her laconic neighbor; to Greg (Santino Fontana), one of Josh’s best friends; and, most recently, Nathaniel (Scott Michael Foster), a supremely hot and evil colleague at her West Covina law firm. For a time, she even entrances Josh, and the pair rush into marriage, only for it all to end in disaster; the most recent season ended with Josh leaving Rebecca at the altar, setting her on a quest for revenge.

“Crazy Ex-Girlfriend’s” defining characteristic is a joyfully caustic streak. It’s a series that announced bartender Greg’s alcoholism and newfound sobriety with a rousing Irish drinking song. Nathaniel kicked off a serenade to Rebecca by crooning “Unfortunately, I want to have sex with you,” and somehow emerged from the song as a more viable romantic prospect than he was when he started. Women are hardly immune from this: Valencia once ended a quasi-protest song making a mockery of empowerment feminism called “Women Gotta Stick Together” by declaring “The truth is you’re all fat sluts / And that’s called sisterhood!”

And yet, the show’s sense of humor isn’t relentlessly negative: rather, it acts as a kind of moral and intellectual defoliant, scrubbing away so many of the absurd pretenses that linger on the face of our culture like irksomely persistent zits.

In the world of “Crazy Ex-Girlfriend,” it’s self-evident that not everything a woman does is inherently empowering; that beauty standards are ridiculous and achieving them takes an enormous amount of work; that an obsessive focus on achievement can drive women to serious depression and destructive rivalries; that pretty much everyone could benefit from therapy; that magazines aimed at teenagers sometimes do great journalism; that doing good things for bad reasons can still achieve good ends even if doing them doesn’t make you a good person; that small cities’ problems and idiosyncrasies can be charming while still being problems; that middle-aged women still deserve romance and career aspirations; that conventional hotness is no measure of attraction or goodness; that friendship is sometimes asymmetrical and sometimes even the best friends break up. The “Crazy Ex-Girlfriend” at the center of the show may have a disturbing tendency to pull everyone else into her orbit, but the morals, ideas and basic good sense that generally assert themselves in West Covina still feel decidedly sane.

And when “Crazy Ex-Girlfriend” gives those of us in the audience permission to go a little mad ourselves, it does so in a way that feels like a huge relief, but coupled with the promise that we won’t fly too far out of bounds. Unlike plenty of other anti-hero shows and their legions of fans who can’t tell the difference between lionization and condemnation, “Crazy Ex-Girlfriend” has never lost sight of the idea that while Rebecca is deliciously fun to watch, there’s no way that any sensible person would actually want to be her.

“Let’s Generalize About Men,” for example, is full of acknowledgements that what the women are doing is an inherently unreasonable ritual: none of them actually believe that all 3.6 billion men are identical thoughtless dummies, and none of them are going to carry those assumptions with them out into the world. It’s just that sometimes when male misbehavior seems to be absolutely everywhere, the only way out seems to be through.

The same true with a number from the show’s second season, “Friendtopia”:

A gloriously demented parody of Spice Girls-era pop, the song featured Rebecca, Heather and Valencia plotting a dystopia-like “Sweet Valley High” meets “1984.” Though your average girl squad might not have as one of its stated goals “take control of the banks,” no matter how much it praises the power of girl power, “Friendtopia” takes the concept so far in the direction of its logical conclusion that it comes out the other side to capture something true. In a world where Donald Trump can be president, why not fantasize about a trio of thirty-something women staging a coup and serving bottomless mimosas on the White House lawn. Okay, the answer is obviously democratic norms, but it’s not as if “Friendtopia” or “Crazy Ex-Girlfriend” ever loses sight of that for a second: the point is to allow you to purge bad feelings in a gut-level roll of laughter rather than to encourage you to ” to braid each other’s hair / Then cut each other’s braids / Connect the braids to build a rope / To hang all of Congress!”

In that sense, “Crazy Ex-Girlfriend” is a safe space in the absolute best sense. Watching the new episode each week isn’t about seeking shelter from vulnerability, or limping out of the harsh political reality of this era to lick my wounds. Rather, it’s a haven where I can express all my bad feelings, purge them, and then reemerge feisty and energized and with my moral compass freshly recalibrated. The world around me may be broken, but “Crazy Ex-Girlfriend” gives me confidence that I haven’t lost sight of solid ground.