Skip to content

Fixed unbound global variables in pywin.dialogs.ideoptions.OptionsPropPage's OnFormat* methods + re-enable pyright's reportUnboundVariable#2283

Merged
Avasam merged 9 commits intomhammond:mainfrom
Avasam:pyright-unbound-globals
Nov 13, 2024
Merged

Fixed unbound global variables in pywin.dialogs.ideoptions.OptionsPropPage's OnFormat* methods + re-enable pyright's reportUnboundVariable#2283
Avasam merged 9 commits intomhammond:mainfrom
Avasam:pyright-unbound-globals

Conversation

@Avasam
Copy link
Copy Markdown
Collaborator

@Avasam Avasam commented Jun 4, 2024

Looking at the implementation of interact.SaveFontPreferences this almost certainly meant to use the variables in interact. Although these still fail because calling self.GetFormat results in AttributeError: 'PyCPropertyPage' object has no attribute 'GetFormat':

>>> from pywin.dialogs import ideoptions; ideoptions.OptionsPropPage().OnFormatInput(None,None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Python39\lib\site-packages\Pythonwin\pywin\dialogs\ideoptions.py", line 122, in OnFormatInput
    fmt = self.GetFormat(formatInput)
  File "C:\Program Files\Python39\lib\site-packages\Pythonwin\pywin\mfc\object.py", line 24, in __getattr__
    return getattr(o, attr)
AttributeError: 'PyCPropertyPage' object has no attribute 'GetFormat'

For all I know these methods might always have been broken in the past 25 years. At least this allows us to turn on reportUnboundVariable in pyright.

Comment thread CHANGES.txt Outdated
@Avasam Avasam changed the title Fixed unbound global variables in pywin.dialogs.ideoptions.OptionsPropPage's OnFormat* methods Fixed unbound global variables in pywin.dialogs.ideoptions.OptionsPropPage's OnFormat* methods + re-enable pyright's reportUnboundVariable Oct 4, 2024
@Avasam Avasam requested a review from mhammond October 18, 2024 18:40
Comment thread pyrightconfig.json Outdated
Copy link
Copy Markdown
Owner

@mhammond mhammond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine but I don't understand why the adodbapi change is in this. This also doesn't need a changelog.

@Avasam
Copy link
Copy Markdown
Collaborator Author

Avasam commented Nov 11, 2024

This seems fine but I don't understand why the adodbapi change is in this.

It's a reported unbound variable for os.environ at line 54. (Meaning it fixes the getenv macro) It's such a tiny change I figured it'd be passable in a single PR to fix all reportUnboundVariables at once.
If not then I'll just split it off and re-enable the warning for now.

Edit: Looks like it's done in #2324 so I probably forgot to split it off.

This also doesn't need a changelog.

Ok !

@Avasam Avasam merged commit 0023fd3 into mhammond:main Nov 13, 2024
@Avasam Avasam deleted the pyright-unbound-globals branch November 13, 2024 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants