“We’re open to any age/gender identity/non-identity,” they added, “so long as you didn’t vote for Trump.

In the same neighborhood, a woman posted an ad searching for someone to take over her room: “Trump supporters this is not the house for you (no, seriously),” she wrote.

For her part, Ms. Kian, who works at Amideast, a nonprofit that focuses on educational opportunities for Middle Eastern and African students, is fine with taking the extra step to make sure her political filter extends to her home.

Ms. Kian, who has American and Iranian citizenship and was raised Muslim, said the idea of the no-Trump clause started out as a joke. But it grew serious, she said, after the president signed an executive order that barred people from seven predominantly Muslim countries from entering the United States.

“Anybody who is on board with that kind of thinking is not welcome,” she said. Whoever ends up living with her will pay $1,300 to share the top floor of the house. (Her parents live downstairs.) People who support Mr. Trump, she said, would not be interested in living in her “raging liberal” house.

“Frankly, it would not work out,” Ms. Kian said in an interview. “That person would not be comfortable here because we bash Trump nightly.”

People like Ms. Kian may be closing themselves off to others, but their actions are legal, according to Sheila C. Salmon, a Washington lawyer who specializes in housing law. Political views are not protected under the Fair Housing Act, which prohibits discrimination based on such factors as race, religion, national origin and disability.