code-base-investigator icon indicating copy to clipboard operation
code-base-investigator copied to clipboard

Add missing type hints

Open Pennycook opened this issue 9 months ago • 0 comments

Feature/behavior summary

Several legacy functions are missing type hints.

Although we've made good progress in adding missing type hints as we've developed new features, we still have a backlog of functionality that we haven't touched in some time.

Request attributes

  • [x] Would this be a refactor of existing code?
  • [ ] Does this proposal require new package dependencies?
  • [ ] Would this change break backwards compatibility?

Related issues

No response

Solution description

We need to add type hints to the functions in the following files:

  • [ ] codebasin/init.py
  • [ ] codebasin/config.py
  • [ ] codebasin/file_parser.py
  • [ ] codebasin/file_source.py
  • [ ] codebasin/finder.py
  • [ ] codebasin/language.py
  • [ ] codebasin/platform.py
  • [ ] codebasin/preprocessor.py
  • [ ] codebasin/report.py
  • [ ] codebasin/tree.py
  • [ ] codebasin/util.py

...and/or refactor the code to replace the functionality in these files.

Additional notes

Applying the following patch enables flake8 to identify all the functions with missing type hints:

--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -51,6 +51,7 @@ repos:
           [
             flake8-debugger,
             flake8-use-fstring,
+            flake8-annotations,
           ]
         args:
           [

At the time of writing, there are 573 instances of missing type hints. I'd like to enable this as part of the CI, but it probably makes sense to wait until we've addressed some of these.

Pennycook avatar Apr 07 '25 07:04 Pennycook