ronaldoussoren / pyobjc

The Python <-> Objective-C Bridge with bindings for macOS frameworks
https://pyobjc.readthedocs.io
563 stars 47 forks source link

keyword arguments for __new__ method generated from initWith* are weird if all caps #623

Closed rndblnch closed 3 weeks ago

rndblnch commented 1 month ago

The automatic generation of keyword arguments name for new method from initWith* just turns the first letter of the first argument to lowercase. But when the first argument is all caps it seems not appropriate, eg:

pdf = PDFDocument.alloc().initWithURL(url) leads to pdf = PDFDocument(uRL=url) (notice the weird uRL parameter)

I have a small patch for Lib/objc/_transform.py fixing that, will open a PR

Platform information

pyobjc 10.3+

ronaldoussoren commented 3 weeks ago

Thanks for the report and fix. I've slightly tweaked your patch to properly handle "initWithX:y:" and added a test case.