richfromm / slack2discord

A Discord client that imports Slack-exported JSON chat history to Discord channel(s).
GNU General Public License v3.0
8 stars 3 forks source link

Add mypy typing hints and get mypy and flake8 style checks to pass #35

Closed richfromm closed 1 year ago

richfromm commented 1 year ago

This is a bit more complicated than I had hoped. There are some areas where mypy gets a bit confused, and there are more uses of Optional[] and cast() than I'm comfortable with. At least some of this is caused by instances in which objects might be None for a dry run only, but not for a real execution. And then those cases propagate.

I suspect there may be more sophisticated things I could be doing with typing hints that might help, but there's a limit to how much effort I wanted to put into this.

mypy now passes. While I was at it, I added flake8 style checks as well. For now these both need to be run manually, but I will look into automating this (with GitHub Actions, see https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python) next. For now:

mypy slack2discord.py
flake8 slack2discord.py slack2discord

I may also look into pylint in the future.

I moved the primary dependencies into requirements.txt (the .pyv file is now a symlink to that), and put dev only dependencies in requirements-dev.txt. Perhaps eventually I'll add real packaging.