Skip to content

chore: more pre-commit checking#2257

Merged
hoodmane merged 6 commits intopyodide:mainfrom
henryiii:henryiii/chore/precom2
Mar 8, 2022
Merged

chore: more pre-commit checking#2257
hoodmane merged 6 commits intopyodide:mainfrom
henryiii:henryiii/chore/precom2

Conversation

@henryiii
Copy link
Contributor

@henryiii henryiii commented Mar 7, 2022

  • chore: clean up flake8 and mypy
  • chore: add spellcheck
  • chore: add shellcheck

This cleans up the flake8 & mypy checks, adds a bit of spell checking, and a linter for shell scripts.

python/typeshed#7453 will help, along with python/typeshed#7452 (already fixed in typeshed).

@henryiii henryiii force-pushed the henryiii/chore/precom2 branch from d479ead to 7531cc5 Compare March 7, 2022 22:30
try:
return "".join(traceback.format_exception_only(type(e), e))
finally:
e = None # type: ignore
Copy link
Member

Choose a reason for hiding this comment

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

Ah I guess this isn't needed since e wasn't thrown down the stack from this function, so e's traceback won't contain a reference to this scope hence no reference loop to break.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it does cause a problem, I think you want del e rather than e = None.

Copy link
Member

Choose a reason for hiding this comment

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

I copied this from the Python source code. Which doesn't mean that it is the right way to do things of course. It seems that in the CPython source code for v3.10.2 there are 32 instances of finally: some_var = None and 36 instances of finally: del some_var.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Python source code is not type checked, so there's no strong difference between x = None and del x. But with type checking, there is a strong differentiator - the former requires x to have an Optional type, which complicates all other usages. While the del does not.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the explanation!


gunzip -rf f2c/*

cd f2c
Copy link
Member

@hoodmane hoodmane Mar 7, 2022

Choose a reason for hiding this comment

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

I'm not convinced we should have this file in here at all. Again, it looks like it's specifically for OSX. Is there really no better way to install f2c on osx than using this script? I guess having an untested and possibly slightly broken script is better than none?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe it could be added to homebrew? I see it in macPorts.

Copy link
Member

Choose a reason for hiding this comment

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

Well I certainly won't do that, but it would be great if someone else would. In the meantime leaving this unmaintained script here is less work than fixing the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd do it if it wasn't so annoying. No versioned link to the files AFAICT, and brew's not going to like that. Barely even versions (dates, I think).

Copy link
Member

@hoodmane hoodmane left a comment

Choose a reason for hiding this comment

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

Thanks @henryiii nice to see all these typos fixes and other beautiful maintenance work.

@hoodmane
Copy link
Member

hoodmane commented Mar 7, 2022

We really need to get rid of the line number in test_console_html it's not acceptable for that test to break every time _pyodide/console.py is modified.

>>> Test()
[[;;;terminal-error]Traceback (most recent call last):
File \"/lib/{PYVERSION}/site-packages/_pyodide/console.py\", line 465, in repr_shorten
File \"/lib/{PYVERSION}/site-packages/_pyodide/console.py\", line """
Copy link
Member

Choose a reason for hiding this comment

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

I was thinking of something like result = re.sub("line [0-9]*", "line xxx", result) but I suppose this gets the job done too.

Copy link
Member

Choose a reason for hiding this comment

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

I think doing the regex substitution is preferable because assert x == y gives better pytest error messages than assert x.endswith(y).

@henryiii henryiii force-pushed the henryiii/chore/precom2 branch from e64d93c to 4d3fad5 Compare March 8, 2022 02:58
@hoodmane hoodmane merged commit 4f8b0a0 into pyodide:main Mar 8, 2022
@henryiii henryiii deleted the henryiii/chore/precom2 branch March 8, 2022 15:13
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.

2 participants