Skip to content

Provide Fallback Name Support for Job Callbacks without __name__ #4992

@sometastycake

Description

@sometastycake

Steps to Reproduce

I have a job, defined as

from telegram.ext import ContextTypes

class Job:

    async def __call__(self, context: ContextTypes.DEFAULT_TYPE):
        ...

application.job_queue.run_repeating(
  callback=Job(),
  interval=timedelta(
      seconds=30,
  ),
)

And I get an error

AttributeError: 'Job' object has no attribute '__name__'. Did you mean: '__ne__'?

Expected behaviour

Job takes the name of the class as his name

Actual behaviour

The code crashes with an error AttributeError: 'Job' object has no attribute '__name__'. Did you mean: '__ne__'?

Operating System

macOS 13.4.1

Version of Python, python-telegram-bot & dependencies

Python: 3.11.3
Python-telegram-bot: 22.3
APScheduler: 3.10.1

Relevant log output

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions