Skip to content

Typechecking improvements #1738

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

Closed
wants to merge 3 commits into from

Conversation

cspotcode
Copy link
Collaborator

@cspotcode cspotcode commented Apr 29, 2023

This PR includes several things, some of which might be rejected. But they're related closely enough, I thought it easier to open one PR for feedback, then modify to remove the stuff that doesn't pass review.

adds pyright typechecking

make pyright

Configured by pyrightconfig.json. The config can technically go into pyproject.toml, but the json config has nice editor tab-completion which makes it easier to tweak.

Adds auto-generated Makefile and justfile

# All 3x do the same thing
python ./make.py lint
make lint
just lint

Probably we don't want both of these, but just for sake of demonstration. When make.py starts, it automatically re-writes these files. Then they're committed to git. So they will only change if you yourself have made changes to make.py, and then you can commit the changes to git.

Nice thing about justfile: you can be in any directory and type just lint. It will always run commands from the project root.

Splits lint logs on CI

ruff, mypy, and pyright logs appear as 3x separate sections in Github Actions results. I wired it up so that all 3 will always run even if an earlier one fails.

make.py --help organized into sections

A nice feature of Typer: you can organize the subcommands into sections. I split them into Docs and Coding; that name's not great. Maybe Dev?

image


Reviewing pyright diagnostics

If you're using VSCode and want to review the outstanding VSCode diagnostics to decide which we fix and which we disable, you can use this .vscode/settings.json

{
    "python.analysis.diagnosticMode": "workspace",
    "python.languageServer": "Pylance"
}

Then open the Problems pane and sort by the diagnostic you want to see.

image

@cspotcode cspotcode force-pushed the typecheck-ci branch 5 times, most recently from 7ff6dc0 to c86440d Compare April 29, 2023 16:26
@cspotcode
Copy link
Collaborator Author

4k lines of errors from pyright, not surprising since I configured it in strict mode and then disabled a few checks that were not really things we could reasonably fix.

https://github.com/pythonarcade/arcade/actions/runs/4839729643/jobs/8624935183?pr=1738

If anyone feels like taking a look, maybe some of those diagnostics we want to fix in follow-up PRs, and others we disable?

@cspotcode
Copy link
Collaborator Author

Some low-hanging fruit we could address:

arcade\paths.py
  arcade\paths.py:18:5 - information: Function "_spot_is_blocked" is not accessed (reportUnusedFunction)
arcade\__pyinstaller\hook-arcade.py
  arcade\__pyinstaller\hook-arcade.py:16:6 - warning: Import "PyInstaller.compat" could not be resolved from source (reportMissingModuleSource)
arcade\examples\array_backed_grid.py
  arcade\examples\array_backed_grid.py:55:17 - information: Variable "column" is not accessed (reportUnusedVariable)
arcade\examples\array_backed_grid_buffered.py
  arcade\examples\array_backed_grid_buffered.py:69:17 - information: Variable "column" is not accessed (reportUnusedVariable)
arcade\examples\asteroid_smasher.py
  arcade\examples\asteroid_smasher.py:215:13 - information: Variable "i" is not accessed (reportUnusedVariable)
  arcade\examples\asteroid_smasher.py:228:13 - information: Variable "i" is not accessed (reportUnusedVariable)
  arcade\examples\asteroid_smasher.py:318:17 - information: Variable "i" is not accessed (reportUnusedVariable)
  arcade\examples\asteroid_smasher.py:339:17 - information: Variable "i" is not accessed (reportUnusedVariable)
  arcade\examples\asteroid_smasher.py:360:17 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\background_parallax.py
  arcade\examples\background_parallax.py:156:20 - information: Variable "depth" is not accessed (reportUnusedVariable)
arcade\examples\bloom_defender.py
  arcade\examples\bloom_defender.py:221:13 - information: Variable "i" is not accessed (reportUnusedVariable)
  arcade\examples\bloom_defender.py:228:13 - information: Variable "i" is not accessed (reportUnusedVariable)
  arcade\examples\bloom_defender.py:297:21 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\dual_stick_shooter.py
  arcade\examples\dual_stick_shooter.py:139:13 - information: Function "on_connect" is not accessed (reportUnusedFunction)
  arcade\examples\dual_stick_shooter.py:144:13 - information: Function "on_disconnect" is not accessed (reportUnusedFunction)
  arcade\examples\dual_stick_shooter.py:205:13 - information: Variable "shoot_x" is not accessed (reportUnusedVariable)
  arcade\examples\dual_stick_shooter.py:205:22 - information: Variable "shoot_y" is not accessed (reportUnusedVariable)
arcade\examples\easing_example_1.py
  arcade\examples\easing_example_1.py:55:21 - information: Variable "ey" is not accessed (reportUnusedVariable)
arcade\examples\full_screen_example.py
  arcade\examples\full_screen_example.py:54:9 - information: Variable "left" is not accessed (reportUnusedVariable)
  arcade\examples\full_screen_example.py:54:29 - information: Variable "bottom" is not accessed (reportUnusedVariable)
arcade\examples\gui_flat_button.py
  arcade\examples\gui_flat_button.py:55:13 - information: Function "on_click_settings" is not accessed (reportUnusedFunction)
arcade\examples\gui_ok_messagebox.py
  arcade\examples\gui_ok_messagebox.py:60:13 - information: Function "on_message_box_close" is not accessed (reportUnusedFunction)
arcade\examples\gui_slider.py
  arcade\examples\gui_slider.py:36:13 - information: Function "on_change" is not accessed (reportUnusedFunction)
arcade\examples\gui_widgets.py
  arcade\examples\gui_widgets.py:52:13 - information: Function "on_click_flatbutton" is not accessed (reportUnusedFunction)
  arcade\examples\gui_widgets.py:61:13 - information: Function "on_click_texture_button" is not accessed (reportUnusedFunction)
arcade\examples\lines_buffered.py
  arcade\examples\lines_buffered.py:48:23 - information: Variable "name" is not accessed (reportUnusedVariable)
  arcade\examples\lines_buffered.py:51:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\maze_recursive.py
  arcade\examples\maze_recursive.py:48:13 - information: Variable "column" is not accessed (reportUnusedVariable)
arcade\examples\performance_statistics.py
  arcade\examples\performance_statistics.py:96:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\procedural_caves_cellular.py
  arcade\examples\procedural_caves_cellular.py:174:13 - information: Variable "step" is not accessed (reportUnusedVariable)
arcade\examples\shape_list_demo_3.py
  arcade\examples\shape_list_demo_3.py:68:21 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\shape_list_demo_skylines.py
  arcade\examples\shape_list_demo_skylines.py:78:13 - information: Variable "i" is not accessed (reportUnusedVariable)
  arcade\examples\shape_list_demo_skylines.py:121:29 - information: Variable "i" is not accessed (reportUnusedVariable)
  arcade\examples\shape_list_demo_skylines.py:13:5 - information: "create_rectangle_filled" is imported more than once (reportDuplicateImport)
arcade\examples\shapes.py
  arcade\examples\shapes.py:82:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\snow.py
  arcade\examples\snow.py:52:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\sprite_bouncing_coins.py
  arcade\examples\sprite_bouncing_coins.py:85:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\sprite_bullets.py
  arcade\examples\sprite_bullets.py:73:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\sprite_bullets_aimed.py
  arcade\examples\sprite_bullets_aimed.py:75:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\sprite_change_coins.py
  arcade\examples\sprite_change_coins.py:62:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\sprite_collect_coins.py
  arcade\examples\sprite_collect_coins.py:71:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\sprite_collect_coins_background.py
  arcade\examples\sprite_collect_coins_background.py:71:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\sprite_collect_coins_diff_levels.py
  arcade\examples\sprite_collect_coins_diff_levels.py:78:13 - information: Variable "i" is not accessed (reportUnusedVariable)
  arcade\examples\sprite_collect_coins_diff_levels.py:91:13 - information: Variable "i" is not accessed (reportUnusedVariable)
  arcade\examples\sprite_collect_coins_diff_levels.py:104:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\sprite_collect_coins_move_bouncing.py
  arcade\examples\sprite_collect_coins_move_bouncing.py:96:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\sprite_collect_coins_move_circle.py
  arcade\examples\sprite_collect_coins_move_circle.py:89:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\sprite_collect_coins_move_down.py
  arcade\examples\sprite_collect_coins_move_down.py:90:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\sprite_collect_rotating.py
  arcade\examples\sprite_collect_rotating.py:73:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\sprite_explosion_bitmapped.py
  arcade\examples\sprite_explosion_bitmapped.py:112:13 - information: Variable "coin_index" is not accessed (reportUnusedVariable)
arcade\examples\sprite_explosion_particles.py
  arcade\examples\sprite_explosion_particles.py:195:13 - information: Variable "coin_index" is not accessed (reportUnusedVariable)
  arcade\examples\sprite_explosion_particles.py:280:21 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\sprite_follow_simple.py
  arcade\examples\sprite_follow_simple.py:96:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\sprite_follow_simple_2.py
  arcade\examples\sprite_follow_simple_2.py:113:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\sprite_move_animation.py
  arcade\examples\sprite_move_animation.py:115:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\sprite_move_scrolling_shake.py
  arcade\examples\sprite_move_scrolling_shake.py:87:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\sprite_no_coins_on_walls.py
  arcade\examples\sprite_no_coins_on_walls.py:71:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\view_instructions_and_game_over.py
  arcade\examples\view_instructions_and_game_over.py:79:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\gl\game_of_life_colors.py
  arcade\examples\gl\game_of_life_colors.py:176:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\perf_test\stress_test_collision_arcade.py
  arcade\examples\perf_test\stress_test_collision_arcade.py:88:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\examples\perf_test\stress_test_draw_moving_arcade.py
  arcade\examples\perf_test\stress_test_draw_moving_arcade.py:89:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\experimental\bloom_multilayer_defender.py
  arcade\experimental\bloom_multilayer_defender.py:231:13 - information: Variable "i" is not accessed (reportUnusedVariable)
  arcade\experimental\bloom_multilayer_defender.py:238:13 - information: Variable "i" is not accessed (reportUnusedVariable)
  arcade\experimental\bloom_multilayer_defender.py:320:21 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\experimental\render_offscreen_animated.py
  arcade\experimental\render_offscreen_animated.py:23:9 - information: Variable "star_no" is not accessed (reportUnusedVariable)
  arcade\experimental\render_offscreen_animated.py:79:13 - information: Variable "i" is not accessed (reportUnusedVariable)
  arcade\experimental\render_offscreen_animated.py:121:29 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\experimental\shapes_buffered_2_glow.py
  arcade\experimental\shapes_buffered_2_glow.py:49:13 - information: Variable "i" is not accessed (reportUnusedVariable)
  arcade\experimental\shapes_buffered_2_glow.py:61:13 - information: Variable "i" is not accessed (reportUnusedVariable)
  arcade\experimental\shapes_buffered_2_glow.py:75:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\experimental\sprite_collect_coins_minimap.py
  arcade\experimental\sprite_collect_coins_minimap.py:88:13 - information: Variable "i" is not accessed (reportUnusedVariable)
arcade\gl\types.py
  arcade\gl\types.py:329:13 - information: Variable "self_attrib" is not accessed (reportUnusedVariable)
  arcade\gl\types.py:330:17 - information: Variable "other_attrib" is not accessed (reportUnusedVariable)
arcade\gui\examples\button_with_text.py
  arcade\gui\examples\button_with_text.py:181:13 - information: Function "on_change" is not accessed (reportUnusedFunction)
arcade\gui\examples\dropdown.py
  arcade\gui\examples\dropdown.py:24:13 - information: Function "on_change" is not accessed (reportUnusedFunction)
arcade\gui\examples\style_v2.py
  arcade\gui\examples\style_v2.py:98:13 - information: Function "change_style" is not accessed (reportUnusedFunction)
  arcade\gui\examples\style_v2.py:106:13 - information: Function "toggle" is not accessed (reportUnusedFunction)
arcade\gui\examples\toggle.py
  arcade\gui\examples\toggle.py:22:13 - information: Function "print_oon_change" is not accessed (reportUnusedFunction)
arcade\gui\widgets\__init__.py
  arcade\gui\widgets\__init__.py:526:34 - information: Variable "data" is not accessed (reportUnusedVariable)
arcade\texture\loading.py
  arcade\texture\loading.py:54:5 - information: Function "_load_tilemap_texture" is not accessed (reportUnusedFunction)
arcade\tilemap\tilemap.py
  arcade\tilemap\tilemap.py:394:13 - information: Variable "tileset_key" is not accessed (reportUnusedVariable)
  arcade\tilemap\tilemap.py:396:21 - information: Variable "tile_key" is not accessed (reportUnusedVariable)
tests\conftest.py
  tests\conftest.py:5:12 - error: Import "arcade_accelerate" could not be resolved (reportMissingImports)
tests\integration\examples\check_examples_2.py
  tests\integration\examples\check_examples_2.py:22:37 - error: Unsupported escape sequence in string literal (reportInvalidStringEscapeSequence)
  tests\integration\examples\check_examples_2.py:22:39 - error: Unsupported escape sequence in string literal (reportInvalidStringEscapeSequence)
tests\integration\examples\test_all_examples.py
  tests\integration\examples\test_all_examples.py:71:12 - information: Import "pyglet" is not accessed (reportUnusedImport)
tests\integration\tutorials\test_all_tutoirals.py
  tests\integration\tutorials\test_all_tutoirals.py:69:12 - information: Import "pyglet" is not accessed (reportUnusedImport)
tests\unit\test_example_docstrings.py
  tests\unit\test_example_docstrings.py:33:23 - information: Variable "is_pkg" is not accessed (reportUnusedVariable)
tests\unit\test_math.py
  tests\unit\test_math.py:8:8 - information: Import "arcade" is not accessed (reportUnusedImport)
tests\unit\atlas\test_basics.py
  tests\unit\atlas\test_basics.py:40:13 - information: Variable "region_a" is not accessed (reportUnusedVariable)
  tests\unit\atlas\test_basics.py:41:13 - information: Variable "region_b" is not accessed (reportUnusedVariable)
  tests\unit\atlas\test_basics.py:57:5 - information: Variable "slot_a" is not accessed (reportUnusedVariable)
  tests\unit\atlas\test_basics.py:57:13 - information: Variable "region_a" is not accessed (reportUnusedVariable)
  tests\unit\atlas\test_basics.py:58:5 - information: Variable "slot_b" is not accessed (reportUnusedVariable)
  tests\unit\atlas\test_basics.py:58:13 - information: Variable "region_b" is not accessed (reportUnusedVariable)
  tests\unit\atlas\test_basics.py:75:13 - information: Variable "region" is not accessed (reportUnusedVariable)
tests\unit\atlas\test_gc.py
  tests\unit\atlas\test_gc.py:2:8 - information: Import "gc" is not accessed (reportUnusedImport)
tests\unit\cache\test_hit_box_cache.py
  tests\unit\cache\test_hit_box_cache.py:3:20 - information: Import "Texture" is not accessed (reportUnusedImport)
tests\unit\cache\test_texture_cache.py
  tests\unit\cache\test_texture_cache.py:4:26 - information: Import "texture_cache" is not accessed (reportUnusedImport)
tests\unit\drawing_support\test_drawing_primitives.py
  tests\unit\drawing_support\test_drawing_primitives.py:124:5 - information: Variable "texture" is not accessed (reportUnusedVariable)
  tests\unit\drawing_support\test_drawing_primitives.py:125:5 - information: Variable "scale" is not accessed (reportUnusedVariable)
tests\unit\drawing_support\test_point_rotation.py
  tests\unit\drawing_support\test_point_rotation.py:1:8 - information: Import "pytest" is not accessed (reportUnusedImport)
  tests\unit\drawing_support\test_point_rotation.py:2:8 - information: Import "arcade" is not accessed (reportUnusedImport)
tests\unit\gl\test_opengl_framebuffer.py
  tests\unit\gl\test_opengl_framebuffer.py:115:5 - information: Variable "fb" is not accessed (reportUnusedVariable)
tests\unit\gl\test_opengl_gc.py
  tests\unit\gl\test_opengl_gc.py:78:5 - information: Variable "texture" is not accessed (reportUnusedVariable)
  tests\unit\gl\test_opengl_gc.py:80:5 - information: Variable "texture" is not accessed (reportUnusedVariable)
  tests\unit\gl\test_opengl_gc.py:89:5 - information: Variable "buf" is not accessed (reportUnusedVariable)
  tests\unit\gl\test_opengl_gc.py:91:5 - information: Variable "buf" is not accessed (reportUnusedVariable)
  tests\unit\gl\test_opengl_gc.py:100:5 - information: Variable "fb" is not accessed (reportUnusedVariable)
  tests\unit\gl\test_opengl_gc.py:105:5 - information: Variable "fb" is not accessed (reportUnusedVariable)
  tests\unit\gl\test_opengl_gc.py:114:5 - information: Variable "prog" is not accessed (reportUnusedVariable)
  tests\unit\gl\test_opengl_gc.py:116:5 - information: Variable "prog" is not accessed (reportUnusedVariable)
  tests\unit\gl\test_opengl_gc.py:138:9 - information: Variable "compute_shader" is not accessed (reportUnusedVariable)
  tests\unit\gl\test_opengl_gc.py:140:9 - information: Variable "compute_shader" is not accessed (reportUnusedVariable)
  tests\unit\gl\test_opengl_gc.py:149:5 - information: Variable "query" is not accessed (reportUnusedVariable)
  tests\unit\gl\test_opengl_gc.py:151:5 - information: Variable "query" is not accessed (reportUnusedVariable)
tests\unit\gl\test_opengl_program.py
  tests\unit\gl\test_opengl_program.py:124:5 - information: Expression value is unused (reportUnusedExpression)
  tests\unit\gl\test_opengl_program.py:3:8 - information: Import "arcade" is not accessed (reportUnusedImport)
  tests\unit\gl\test_opengl_program.py:172:5 - information: Variable "program" is not accessed (reportUnusedVariable)
  tests\unit\gl\test_opengl_program.py:218:5 - information: Variable "program" is not accessed (reportUnusedVariable)
  tests\unit\gl\test_opengl_program.py:231:9 - information: Variable "program" is not accessed (reportUnusedVariable)
  tests\unit\gl\test_opengl_program.py:244:9 - information: Variable "program" is not accessed (reportUnusedVariable)
tests\unit\gl\test_opengl_types.py
  tests\unit\gl\test_opengl_types.py:2:8 - information: Import "arcade" is not accessed (reportUnusedImport)
  tests\unit\gl\test_opengl_types.py:40:5 - information: Variable "descr" is not accessed (reportUnusedVariable)
tests\unit\gui\test_event_order.py
  tests\unit\gui\test_event_order.py:17:9 - information: Function "record_mng" is not accessed (reportUnusedFunction)
  tests\unit\gui\test_event_order.py:42:17 - information: Function "record_mng" is not accessed (reportUnusedFunction)
  tests\unit\gui\test_event_order.py:83:17 - information: Function "record_widget" is not accessed (reportUnusedFunction)
  tests\unit\gui\test_event_order.py:87:17 - information: Function "record_mng" is not accessed (reportUnusedFunction)
tests\unit\gui\test_widget_tree.py
  tests\unit\gui\test_widget_tree.py:51:9 - information: Function "on_event" is not accessed (reportUnusedFunction)
tests\unit\physics_engine\test_physics_engine.py
tests\unit\sprite\test_sprite_animated_old.py  tests\unit\sprite\test_sprite_animated_old.py:1:8 - information: Import "pytest" is not accessed (reportUnusedImport)
tests\unit\spritelist\test_spatial_hash.py  tests\unit\spritelist\test_spatial_hash.py:38:9 - information: Variable "i" is not accessed (reportUnusedVariable)
tests\unit\spritelist\test_spritelist.py  tests\unit\spritelist\test_spritelist.py:206:5 - information: Expression value is unused (reportUnusedExpression)
  tests\unit\spritelist\test_spritelist.py:24:9 - information: Variable "i" is not accessed (reportUnusedVariable)
tests\unit\text\test_text.py  tests\unit\text\test_text.py:3:8 - information: Import "pytest" is not accessed (reportUnusedImport)
tests\unit\texture\test_load_textures.py  tests\unit\texture\test_load_textures.py:54:9 - information: Variable "i" is not accessed (reportUnusedVariable)
tests\unit\texture\test_texture_transform_render.py  tests\unit\texture\test_texture_transform_render.py:8:5 - information: Import "Transform" is not accessed (reportUnusedImport)
tests\unit\texture\test_textures.py  tests\unit\texture\test_textures.py:21:5 - information: Variable "circle_texture" is not accessed (reportUnusedVariable)  tests\unit\texture\test_textures.py:22:5 - information: Variable "soft_circle_texture" is not accessed (reportUnusedVariable)
  tests\unit\texture\test_textures.py:23:5 - information: Variable "soft_square_texture" is not accessed (reportUnusedVariable)
  tests\unit\texture\test_textures.py:32:5 - information: Variable "explosion_texture_list" is not accessed (reportUnusedVariable)tests\unit\window\test_view.py
  tests\unit\window\test_view.py:3:20 - information: Import "Window" is not accessed (reportUnusedImport)tests\unit\window\test_window.py
  tests\unit\window\test_window.py:2:8 - information: Import "pyglet" is not accessed (reportUnusedImport)  tests\unit\window\test_window.py:4:25 - information: Import "Mat4" is not accessed (reportUnusedImport)3 errors, 1 warning, 144 informations
Completed in 11.26secmake: *** [Makefile:124: pyright] Error 1
(.venv) PS typecheck-ci>

Copy link
Member

@pushfoo pushfoo left a comment

Choose a reason for hiding this comment

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

tl;dr "don't edit this" comments at the top of a file indicate a 100% chance someone will try to edit it

Although making the file clearly grammatically invalid (nothing but comments) can work, it seems better to take this approach:

  1. Don't have the original in the git history, at least not under its final name
  2. Add a linting check to fail build any time someone tries to add it

The downside is this increases build process complexity. I'm already worried about this aspect of the PR, but I'll hold off on approving or requesting changes until I understand its pros and cons better.

@@ -0,0 +1,101 @@
# DO NOT EDIT BY HAND: is automatically re-generated by make.py
Copy link
Member

Choose a reason for hiding this comment

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

Same as the comment on Makefile: if a line like this has to exist, it seems like a problem.

Copy link
Collaborator Author

@cspotcode cspotcode Apr 30, 2023

Choose a reason for hiding this comment

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

We could just .gitignore them. So anyone who wants the convenience of make will get it right after they run make.py for the first time.

The only benefit of versioning it in git is that it exists before the first time you run make.py. After that, you're constantly re-running make.py -- even via make -- which is constantly re-emitting the makefile.

@@ -0,0 +1,133 @@
# DO NOT EDIT BY HAND: is automatically re-generated by make.py
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about this.

We had auto-generated parts before, specifically __init__.py. If I remember correctly, we removed auto-generation in large part due to constant confusion over what needed to be updated.

Copy link
Member

Choose a reason for hiding this comment

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

GitHub is flagging all comments as bright red. To my understanding, the JSON spec does not allow for comments, even if specific parser implementations do.

Is there an alternate config format allowed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I went with pyrightconfig.json because VSCode tab-completes all the fields, unlike with pyproject.toml. The experience of setting it up was much nicer this way. Unfortunately a lot of tools these days use the JSON extension but actually parse it as JSONC. I've added a .gitattributes directive telling Github that pyrightconfig.json files are always JSONC.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried opening the project in PyCharm and it doesn't seem to understand pyrightconfig.json the way VSCode does. So I can move the config into pyproject.toml, I have the changes locally but would like to wait till I get some feedback on if we actually want any of these stricter typechecking rules enables.

def emit_makefile():
with cd_context(PROJECT_ROOT):
with open('Makefile', 'w') as f:
f.write('# DO NOT EDIT BY HAND: is automatically re-generated by make.py\n')
Copy link
Member

Choose a reason for hiding this comment

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

If we're going this route, it may make more sense to also paste above every directive inside the loop. That still might not be enough.

@cspotcode
Copy link
Collaborator Author

Closing since everything here has been extracted to other PRs and merged.

@cspotcode cspotcode closed this May 31, 2023
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