Skip to content

Patch: Document metaprogrammed module attributes #19

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

Merged
merged 5 commits into from
Dec 12, 2021

Conversation

garrettheath4
Copy link
Contributor

@garrettheath4 garrettheath4 commented Aug 11, 2021

Expanded documentation to include dynamically-generated module-level attributes that cannot be detected (by an IDE) or documented (by NumpyDoc) without running the code. Specifically:

  • adafruit_logging.NOTSET
  • adafruit_logging.DEBUG
  • adafruit_logging.INFO
  • adafruit_logging.WARNING
  • adafruit_logging.ERROR
  • adafruit_logging.CRITICAL

are all module-level attributes that are generated using this block of metaprogramming (line 65):

LEVELS = [
    (00, "NOTSET"),
    (10, "DEBUG"),
    (20, "INFO"),
    (30, "WARNING"),
    (40, "ERROR"),
    (50, "CRITICAL"),
]

for level_value, level_name in LEVELS:
    globals()[level_name] = level_value

Expanded documentation to include dynamically-generated module-level attributes
that cannot be detected or documented without running the code. Specifically:

* adafruit_logging.NOTSET
* adafruit_logging.DEBUG
* adafruit_logging.INFO
* adafruit_logging.WARNING
* adafruit_logging.ERROR
* adafruit_logging.CRITICAL

are all module-level attributes that are generated using this block of
metaprogramming (line 65):

```
LEVELS = [
    (00, "NOTSET"),
    (10, "DEBUG"),
    (20, "INFO"),
    (30, "WARNING"),
    (40, "ERROR"),
    (50, "CRITICAL"),
]

for level_value, level_name in LEVELS:
    globals()[level_name] = level_value
```
Copy link
Member

@brentru brentru left a comment

Choose a reason for hiding this comment

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

Thank you for the PR- requesting a few changes.

… type to `Logger.addHandler(..)` docstring, and reverted `level_for(..)` param rename from `level_value` back to `value`

as suggested by @brentru
Copy link
Contributor Author

@garrettheath4 garrettheath4 left a comment

Choose a reason for hiding this comment

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

Replied to 2 comments and resolved suggestions by @brentru

Suggestions were to remove PyCharm-specific code inspection comments, add param type to Logger.addHandler(..) docstring, and revert level_for(..) param rename from level_value back to value

@brentru
Copy link
Member

brentru commented Aug 12, 2021

@garrettheath4 This is failing on black, could you fix this and re-commit. Changes look good.

@FoamyGuy
Copy link
Contributor

I merged main to this branch and resolved the conflicts. Fixed one other pylint issue resulting from renaming some of the arguments in this PR.

Changes look good to me as well.

@FoamyGuy FoamyGuy merged commit 7a188fe into adafruit:main Dec 12, 2021
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Dec 13, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_Logging to 3.7.3 from 3.7.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_Logging#19 from garrettheath4/document-dynamic-levels
  > update rtd py version
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.

3 participants