Skip to content

Source code modernization #32

@vergenzt

Description

@vergenzt

Hi @nedbat! I've been thinking about a few suggestions / requests for this app, but you've mentioned in a few places that the code style is pretty archaic. I'm interested in helping to modernize it. I'm gonna put my tentative todo list here -- obviously 👍'ing or 👎'ing each PR will be up to you, but if you're up for weighing in here that'd be helpful.

  • Auto-format Python code using ruff format (preferably via pre-commit hook?)

  • Lint Python code using ruff check (preferably via pre-commit hook?) & apply suggestions

    • Some of them are more trivial, but I tend to think it's worth it for the consistency. 🤷

    • Here's the current list I'm seeing:

      23 "errors"
      cogapp/__init__.py:7:21: F401 `.cogapp.Cog` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
      cogapp/__init__.py:7:26: F401 `.cogapp.CogUsageError` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
      cogapp/__init__.py:7:41: F401 `.cogapp.main` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
      cogapp/cogapp.py:115:27: E741 Ambiguous variable name: `l`
      cogapp/cogapp.py:118:25: E741 Ambiguous variable name: `l`
      cogapp/cogapp.py:128:58: E741 Ambiguous variable name: `l`
      cogapp/cogapp.py:129:56: E741 Ambiguous variable name: `l`
      cogapp/cogapp.py:161:9: E722 Do not use bare `except`
      cogapp/cogapp.py:429:13: E741 Ambiguous variable name: `l`
      cogapp/cogapp.py:446:21: E741 Ambiguous variable name: `l`
      cogapp/cogapp.py:473:21: E741 Ambiguous variable name: `l`
      cogapp/cogapp.py:492:25: E741 Ambiguous variable name: `l`
      cogapp/cogapp.py:504:17: E741 Ambiguous variable name: `l`
      cogapp/cogapp.py:525:21: E741 Ambiguous variable name: `l`
      cogapp/cogapp.py:568:21: E741 Ambiguous variable name: `l`
      cogapp/cogapp.py:573:25: E741 Ambiguous variable name: `l`
      cogapp/cogapp.py:577:17: E741 Ambiguous variable name: `l`
      cogapp/cogapp.py:704:13: E741 Ambiguous variable name: `l`
      cogapp/test_makefiles.py:29:16: E721 Do not compare types, use `isinstance()`
      cogapp/utils.py:47:9: E741 Ambiguous variable name: `l`
      cogapp/whiteutils.py:45:9: E741 Ambiguous variable name: `l`
      cogapp/whiteutils.py:47:13: E741 Ambiguous variable name: `l`
      cogapp/whiteutils.py:49:13: E741 Ambiguous variable name: `l`
      
  • Convert CogOptions from getopt to argparse

    • I'd probably extract the options & option parsing into a separate cogapp/options.py file. And maybe make the usage string autogenerated based on the configured argument help strings?
  • TBD...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions