Skip to content
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

Improve static type checking #333

Merged
merged 5 commits into from
Apr 21, 2023
Merged

Improve static type checking #333

merged 5 commits into from
Apr 21, 2023

Conversation

dklimpel
Copy link
Contributor

Signed-off-by: Dirk Klimpel [email protected]

@dklimpel
Copy link
Contributor Author

I am not sure if this error is realted to this PR:

check_codestyle: commands[0]> flake8 sygnal/ tests/ setup.py scripts-dev/
Traceback (most recent call last):
  File "/home/runner/work/sygnal/sygnal/.tox/check_codestyle/bin/flake8", line 8, in <module>
    sys.exit(main())
  File "/home/runner/work/sygnal/sygnal/.tox/check_codestyle/lib/python3.7/site-packages/flake8/main/cli.py", line 22, in main
    app.run(argv)
  File "/home/runner/work/sygnal/sygnal/.tox/check_codestyle/lib/python3.7/site-packages/flake8/main/application.py", line 363, in run
    self._run(argv)
  File "/home/runner/work/sygnal/sygnal/.tox/check_codestyle/lib/python3.7/site-packages/flake8/main/application.py", line [35](https://github.com/matrix-org/sygnal/actions/runs/4762765542/jobs/8465376134?pr=333#step:5:36)0, in _run
    self.initialize(argv)
check_codestyle: exit 1 (0.15 seconds) /home/runner/work/sygnal/sygnal> flake8 sygnal/ tests/ setup.py scripts-dev/ pid=1958
.pkg: _exit> python /opt/hostedtoolcache/Python/3.7.16/x64/lib/python3.7/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
  File "/home/runner/work/sygnal/sygnal/.tox/check_codestyle/lib/python3.7/site-packages/flake8/main/application.py", line 330, in initialize
    self.find_plugins(config_finder)
  File "/home/runner/work/sygnal/sygnal/.tox/check_codestyle/lib/python3.7/site-packages/flake8/main/application.py", line 153, in find_plugins
    self.check_plugins = plugin_manager.Checkers(local_plugins.extension)
  File "/home/runner/work/sygnal/sygnal/.tox/check_codestyle/lib/python3.7/site-packages/flake8/plugins/manager.py", line 357, in __init__
    self.namespace, local_plugins=local_plugins
  File "/home/runner/work/sygnal/sygnal/.tox/check_codestyle/lib/python3.7/site-packages/flake8/plugins/manager.py", line 2[38](https://github.com/matrix-org/sygnal/actions/runs/4762765542/jobs/8465376134?pr=333#step:5:39), in __init__
    self._load_entrypoint_plugins()
  File "/home/runner/work/sygnal/sygnal/.tox/check_codestyle/lib/python3.7/site-packages/flake8/plugins/manager.py", line 254, in _load_entrypoint_plugins
    eps = importlib_metadata.entry_points().get(self.namespace, ())
AttributeError: 'EntryPoints' object has no attribute 'get'
  check_codestyle: FAIL code 1 (40.03=setup[[39](https://github.com/matrix-org/sygnal/actions/runs/4762765542/jobs/8465376134?pr=333#step:5:40).88]+cmd[0.15] seconds)
  evaluation failed :( ([40](https://github.com/matrix-org/sygnal/actions/runs/4762765542/jobs/8465376134?pr=333#step:5:41).[40](https://github.com/matrix-org/sygnal/actions/runs/4762765542/jobs/8465376134?pr=333#step:5:41) seconds)

@dklimpel dklimpel marked this pull request as ready for review April 21, 2023 08:06
@dklimpel dklimpel requested a review from a team as a code owner April 21, 2023 08:06
@richvdh
Copy link
Member

richvdh commented Apr 21, 2023

I am not sure if this error is realted to this PR:

It's happening on my PR too (#334), so I guess not

@dklimpel
Copy link
Contributor Author

I have seen that the pipeline also uses Python 3.7. It is EOL in 2 month.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it now possible to mark these files as disallow_untyped_defs = true in mypy.ini?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@DMRobertson DMRobertson left a comment

Choose a reason for hiding this comment

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

Thanks for this. Just a couple of questions:

Copy link
Contributor

@DMRobertson DMRobertson left a comment

Choose a reason for hiding this comment

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

Thanks Dirk!

@DMRobertson DMRobertson merged commit e251fa9 into matrix-org:main Apr 21, 2023
@dklimpel dklimpel deleted the type_hints_tests branch April 21, 2023 12:26
DMRobertson pushed a commit that referenced this pull request Apr 21, 2023
DMRobertson pushed a commit that referenced this pull request Apr 21, 2023
Presumably this fixes complaints from #333 and #334
DMRobertson pushed a commit that referenced this pull request Apr 21, 2023
Needed for unit tests to be happy
DMRobertson pushed a commit that referenced this pull request Apr 21, 2023
* Move from setup.py to pyproject.toml

Co-authored-by: Patrick Cloke <[email protected]>

* Ensure unit tests run

IDK we sometimes have to invoke trial explicitly like this

* Use ruff instead of flake8

And remove py2-style type annotations, which ruff doesn't recognise

Co-authored-by: Patrick Cloke <[email protected]>

* Bump GHA actions

part of matrix-org/synapse#14203

* Run black

Presumably this fixes complaints from #333 and #334

* Move isort config to pyproject

* Also lint stubs

* Bump GHA actions

part of matrix-org/synapse#14203

* Fix an unintended rename in #333

Needed for unit tests to be happy

* Changelog

---------

Co-authored-by: Patrick Cloke <[email protected]>
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