-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static typing: Logger __getattr__
definition causes mypy to not error when missing an attribute
#1660
Comments
hey @nayaverdier - thanks for flagging it! We'll need to look into it as it's slightly more complex than that. There are two reasons we added it 2 years ago:
If we do that suggestion It's hard to know who's doing 2. Now that we're in V2 and Mypy strict typing is in the roadmap, we could look into having a deprecated warning or something if we can't provide type safety by the end of strict typing changes. |
@heitorlessa Thanks for the info. I imagine since Logger subclasses from aws_lambda_powertools import Logger
logger = Logger(service="test")
logger.info("test") Yields the following output:
Using Pyright in vim (which should be very similar to Pylance in VSCode) and with the |
Ah great! If you're seeing in vim, we can then test removing it as a scream test - if anyone complains (Hyrum's Law) we can revert quickly. With the registered_formatter and registered_handler properties, I think it already addresses 99% the needs for accessing something in _logger. We're making a release on Monday (PyPi prod was in maintenance today). Would you like to make a PR to remove it? I can merge and update release notes before releasing it Thank you! |
|
Static type checker used
mypy (project's standard)
AWS Lambda function runtime
3.9
AWS Lambda Powertools for Python version
latest
Static type checker info
The issue here is a lack of output. Running
mypy
with no arguments on the file below does not produce any issues.Code snippet
Possible Solution
Based on python/mypy#13319, the preferred solution seems to be the following:
This appears to resolve the issue on my machine.
The text was updated successfully, but these errors were encountered: