Kalmat / PyWinCtl

Cross-Platform module to get info on and control windows on screen
Other
179 stars 19 forks source link

Improve linux activate #38

Closed MestreLion closed 1 year ago

MestreLion commented 1 year ago

As discussed in #36

Kalmat commented 1 year ago

Hi! The PR failed because of the typing checks. As I mentioned before, this all about of typing is like black magic to me. In fact, I had to create a "dummy" repo (PyWinCtl-Typed) to check there before commiting to master branch and get it full of useless commits (unfortunately it's a try-fail process for me)

In this case, I think the workaround (since we are accessing a private method) can be something like this:

EWMH._setProperty('_NET_ACTIVE_WINDOW', [source, Xlib.X.CurrentTime, self._hWnd.id], self._hWnd) # pyright: ignore[reportUnknownMemberType, reportGeneralTypeIssues] # We expect an error here

Besides... what is this??? # noqa : W0212. Never seen it before!

MestreLion commented 1 year ago

In this case, I think the workaround (since we are accessing a private method) can be something like this:

EWMH._setProperty('_NET_ACTIVE_WINDOW', [source, Xlib.X.CurrentTime, self._hWnd.id], self._hWnd) # pyright: ignore[reportUnknownMemberType, reportGeneralTypeIssues] # We expect an error here

Those warnings are not about accessing a private method, but about accessing an unknown method with an unknown return type.

No need to mute that warning, at least not yet: it might suffice to add def _setProperty(self, _type, data, win=None, mask=None) -> None: to typings/ewmh/ewmh.pyi

Besides... what is this??? # noqa : W0212. Never seen it before!

That's the marker for flake8/pylint/etc to avoid a warning for accessing a private method ;-)

https://pylint.pycqa.org/en/latest/user_guide/messages/warning/protected-access.html

MestreLion commented 1 year ago

It seems adding the method to ewmh.pyi was the solution to that problem.

But... wow, they require full typing, as in list is not acceptable? Geez!!! Ok, will fix that

MestreLion commented 1 year ago

Finally passed the tests!!!

Those last errors were because I added a missing ) -> bool: to LinuxWindow.activate(), which opened a pandora box: the return type was missing from isActive(), which in turn also had a returned value that wasn't typed as bool (what else woyld == be???). Geez!!!