Check existence of user identification number
One of:


Only take a string or a number.
Use str either way.
Work against a bespoke class.

Yes. But I find it better to just use Iterator[str], unless you're using the coroutine aspects of it.
Yeah that's fine. But:


You can just use in rather than any(...).
You don't need the function get_ids you can just use any, like you are now.






Don't use type(...) == int, use isinstance.
Validating user_id should probably happen somewhere else.

I'll make a class as an example to show this.


class UserId:
    __slots__ = ('id',)
    id: int

    def __init__(self, id: int) -&gt; None:
        if not self.valid_id(id):
            raise ValueError("ID should be 9 characters long and all digits.")
        self.id = id

    @staticmethod
    def valid_id(id: int) -&gt; bool:
        if not isinstance(id, int):
            return False
        str_id = str(id)
        return (
            len(str_id) == 9
            and str_id.isdigit()
        )

    def exists(self) -&gt; bool:
        user_id = str(self.id)
        with open('ids.txt') as f:
            return any(user_id == line.strip() for line in f)


print(UserId(123456789).exists())