From 446368ae9e0a425b3f917c066bccec309ec53ba3 Mon Sep 17 00:00:00 2001 From: Spartan322 Date: Fri, 17 Jul 2026 21:36:22 -0400 Subject: [PATCH] Update pre-commit hooks Update ruff-check/ruff-format to v0.15.22 Update mypy to v2.3.0 Update typos to v1.48.0 Update clang-tidy dependency to 22.1.8 Apply clang-tidy fixes --- .pre-commit-config.yaml | 36 +++++++++++-------- docs/contribution/run-build-and-export.md | 2 +- docs/contribution/system-requirements.md | 2 +- .../openvic-extension/classes/GUILabel.cpp | 2 +- .../openvic-extension/classes/GUILabel.hpp | 6 +++- .../openvic-extension/classes/GUIPieChart.hpp | 1 + .../classes/GUIScrollbar.hpp | 2 +- .../singletons/GameSingleton.cpp | 4 +-- .../singletons/GameSingleton.hpp | 3 +- .../singletons/MenuSingleton.hpp | 2 +- .../singletons/MilitaryMenu.cpp | 8 ++--- pyproject.toml | 15 ++++++-- 12 files changed, 53 insertions(+), 30 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 36a27fee..ffd87163 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,14 +24,22 @@ repos: hooks: - id: clang-tidy files: \.(c|h|cpp|hpp|inc)$ - args: [--fix, --quiet, --use-color] + args: + [ + --fix, + --quiet, + --use-color, + -p=compile_commands.json, + -extra-arg=-Wno-unknown-warning-option, + -checks=-modernize-use-bool-literals, + ] types_or: [text] - additional_dependencies: [clang-tidy==19.1.0] + additional_dependencies: [clang-tidy==22.1.8] require_serial: true stages: [manual] # Not automatically triggered, invoked via `pre-commit run --hook-stage manual clang-tidy` - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.2 + rev: v0.15.22 hooks: - id: ruff-check args: [--fix] @@ -42,7 +50,7 @@ repos: types_or: [text] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.13.0 + rev: v2.3.0 hooks: - id: mypy files: \.py$ @@ -60,7 +68,7 @@ repos: types_or: [text] - repo: https://github.com/crate-ci/typos - rev: v1.29.4 + rev: v1.48.0 hooks: - id: typos exclude: | @@ -69,21 +77,21 @@ repos: game/addons/.* ) - - repo: local hooks: - id: make-rst name: make-rst language: python entry: python extension/doc_tools/make_rst.py - args: [ - extension/doc_tools/cache/engine/godot/doc/classes, - extension/doc_tools/cache/engine/godot/modules, - extension/doc_tools/cache/engine/godot/platform, - extension/doc_classes, - --dry-run, - --color - ] + args: + [ + extension/doc_tools/cache/engine/godot/doc/classes, + extension/doc_tools/cache/engine/godot/modules, + extension/doc_tools/cache/engine/godot/platform, + extension/doc_classes, + --dry-run, + --color, + ] pass_filenames: false files: ^(extension/doc_classes)/.*\.xml$ diff --git a/docs/contribution/run-build-and-export.md b/docs/contribution/run-build-and-export.md index 99acd9a4..d0e81db7 100644 --- a/docs/contribution/run-build-and-export.md +++ b/docs/contribution/run-build-and-export.md @@ -8,7 +8,7 @@ With the project installed and system requirements ready: 1. Run `scons` in the project root. * Ensure a `game/bin/openvic/libopenvic` file is produced for your platform (windows, linux, macos) -2. Open Godot, click import, naivgate to the `game` directory and click `Import and Edit`. +2. Open Godot, click import, navigate to the `game` directory and click `Import and Edit`. * Wait for the import to finish, close the editor without saving, then reopen the project in Godot. 3. Press the play button at the top right of the editor. diff --git a/docs/contribution/system-requirements.md b/docs/contribution/system-requirements.md index 539d588b..2f094ecc 100644 --- a/docs/contribution/system-requirements.md +++ b/docs/contribution/system-requirements.md @@ -14,7 +14,7 @@ With Python 3.6+ installed, you can install Scons through pip: ```sh python -m pip install scons ``` -If you get `Defaulting to user installation because normal site-packages is not writeable` then open a command prompt as Administrator and run the command again. When finished call: +If you get `Defaulting to user installation because normal site-packages is not writable` then open a command prompt as Administrator and run the command again. When finished call: ``` scons --version ``` diff --git a/extension/src/openvic-extension/classes/GUILabel.cpp b/extension/src/openvic-extension/classes/GUILabel.cpp index 42bde925..ac2a598d 100644 --- a/extension/src/openvic-extension/classes/GUILabel.cpp +++ b/extension/src/openvic-extension/classes/GUILabel.cpp @@ -222,7 +222,7 @@ void GUILabel::_notification(int what) { } } -GUILabel::GUILabel() : font_size { DEFAULT_FONT_SIZE } {} +GUILabel::GUILabel() {} void GUILabel::clear() { gui_text = nullptr; diff --git a/extension/src/openvic-extension/classes/GUILabel.hpp b/extension/src/openvic-extension/classes/GUILabel.hpp index 0cf62629..bccae7df 100644 --- a/extension/src/openvic-extension/classes/GUILabel.hpp +++ b/extension/src/openvic-extension/classes/GUILabel.hpp @@ -20,6 +20,10 @@ namespace OpenVic { class GUILabel : public godot::Control { GDCLASS(GUILabel, godot::Control) + public: + static constexpr int32_t DEFAULT_FONT_SIZE = 16; + + private: GUI_TOOLTIP_DEFINITIONS using colour_instructions_t = std::vector>; @@ -35,7 +39,7 @@ namespace OpenVic { bool PROPERTY_CUSTOM_PREFIX(auto_adjust_to_content_size, will, false); godot::Ref font; - int32_t PROPERTY(font_size); + int32_t PROPERTY(font_size, DEFAULT_FONT_SIZE); godot::Color PROPERTY(default_colour); GFX::Font::colour_codes_t const* colour_codes = nullptr; godot::Ref currency_texture; diff --git a/extension/src/openvic-extension/classes/GUIPieChart.hpp b/extension/src/openvic-extension/classes/GUIPieChart.hpp index 32ca3505..9e8af214 100644 --- a/extension/src/openvic-extension/classes/GUIPieChart.hpp +++ b/extension/src/openvic-extension/classes/GUIPieChart.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include diff --git a/extension/src/openvic-extension/classes/GUIScrollbar.hpp b/extension/src/openvic-extension/classes/GUIScrollbar.hpp index f20a15f6..ab610c1d 100644 --- a/extension/src/openvic-extension/classes/GUIScrollbar.hpp +++ b/extension/src/openvic-extension/classes/GUIScrollbar.hpp @@ -136,7 +136,7 @@ namespace OpenVic { ReadOnlyClampedValue& slider_value ); - /* Override the main dimension of gui_scollbar's size with the specified length. */ + /* Override the main dimension of gui_scrollbar's size with the specified length. */ void set_length_override(real_t new_length_override); }; } diff --git a/extension/src/openvic-extension/singletons/GameSingleton.cpp b/extension/src/openvic-extension/singletons/GameSingleton.cpp index d4f36be5..03097fe4 100644 --- a/extension/src/openvic-extension/singletons/GameSingleton.cpp +++ b/extension/src/openvic-extension/singletons/GameSingleton.cpp @@ -116,7 +116,7 @@ GameSingleton::GameSingleton() std::bind(&GameSingleton::_on_gamestate_updated, this), std::bind(&Time::get_ticks_usec, Time::get_singleton()), std::bind(&Time::get_ticks_msec, Time::get_singleton()) - }, mapmode { &Mapmode::ERROR_MAPMODE } { + } { ERR_FAIL_COND(singleton != nullptr); singleton = this; } @@ -220,7 +220,7 @@ Error GameSingleton::setup_game(int32_t bookmark_index) { // TODO - remove this temporary crime assignment InstanceManager* instance_manager = get_instance_manager(); ERR_FAIL_NULL_V_MSG(instance_manager, FAILED, "Failed to setup instance manager!"); - + CrimeManager const& crime_manager = definition_manager.get_crime_manager(); for (ProvinceInstance& province : instance_manager->get_map_instance().get_province_instances()) { const crime_index_t crime_index = crime_index_t(type_safe::get(province.index) % crime_manager.get_crime_modifier_count()); diff --git a/extension/src/openvic-extension/singletons/GameSingleton.hpp b/extension/src/openvic-extension/singletons/GameSingleton.hpp index 1c1b0fca..bf539fa5 100644 --- a/extension/src/openvic-extension/singletons/GameSingleton.hpp +++ b/extension/src/openvic-extension/singletons/GameSingleton.hpp @@ -27,7 +27,8 @@ namespace OpenVic { godot::Ref province_shape_texture; godot::Ref province_colour_image; godot::Ref province_colour_texture; - Mapmode const* mapmode; // This should never be null, if no mapmode is set then it'll point to Mapmode::ERROR_MAPMODE + Mapmode const* mapmode = &Mapmode::ERROR_MAPMODE; // This should never be null, if no mapmode is set then it'll point to + // Mapmode::ERROR_MAPMODE godot::Ref terrain_texture; inline static const godot::Vector2i PROPERTY(flag_dims, { 128, 64 }); /* The size in pixels of an individual flag. */ diff --git a/extension/src/openvic-extension/singletons/MenuSingleton.hpp b/extension/src/openvic-extension/singletons/MenuSingleton.hpp index d5cf237a..8751a255 100644 --- a/extension/src/openvic-extension/singletons/MenuSingleton.hpp +++ b/extension/src/openvic-extension/singletons/MenuSingleton.hpp @@ -75,7 +75,7 @@ namespace OpenVic { struct pop_filter_t { pop_size_t count, promotion_demotion_change; - bool selected; + bool selected = false; }; ordered_map pop_filters; diff --git a/extension/src/openvic-extension/singletons/MilitaryMenu.cpp b/extension/src/openvic-extension/singletons/MilitaryMenu.cpp index 9f50f649..d22bce5a 100644 --- a/extension/src/openvic-extension/singletons/MilitaryMenu.cpp +++ b/extension/src/openvic-extension/singletons/MilitaryMenu.cpp @@ -391,19 +391,19 @@ Dictionary MenuSingleton::get_military_menu_info() { war_exhaustion_template_string, war_exhaustion_string, max_war_exhaustion_string ); - static const StringName war_exhaution_localisation_key = "MILITARY_WAR_EXHAUSTION_TOOLTIP"; - static const StringName max_war_exhaution_localisation_key = "MILITARY_MAX_WAR_EXHAUSTION_TOOLTIP"; + static const StringName war_exhaustion_localisation_key = "MILITARY_WAR_EXHAUSTION_TOOLTIP"; + static const StringName max_war_exhaustion_localisation_key = "MILITARY_MAX_WAR_EXHAUSTION_TOOLTIP"; static const String current_effects_localisation_key = "WEX_EFFECTS"; static const String war_exhaustion_tooltip_template_string = "%s%s\n\n%s%s" + get_tooltip_separator() + "%s%s"; ret[military_info_war_exhaustion_tooltip_key] = Utilities::format( war_exhaustion_tooltip_template_string, - tr(war_exhaution_localisation_key).replace( + tr(war_exhaustion_localisation_key).replace( Utilities::get_long_value_placeholder(), war_exhaustion_string ), _make_modifier_effect_contributions_tooltip(*country, *modifier_effect_cache.get_war_exhaustion_monthly()), - tr(max_war_exhaution_localisation_key).replace( + tr(max_war_exhaustion_localisation_key).replace( Utilities::get_long_value_placeholder(), max_war_exhaustion_string ), diff --git a/pyproject.toml b/pyproject.toml index 383a1448..88ee22b5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,11 +36,20 @@ default.extend-ignore-re = [ "id=\"[^\"]+\"", # Ignore scene ids "ExtResource\\(\"[^\"]+\"\\)", # Ignore scene ids ] -type.xml.locale = "en-us" -type.xml.check-filename = false -type.xml.extend-ignore-re = [ + +[tool.typos.type.xml] +locale = "en-us" +check-filename = false +extend-ignore-re = [ '<.* name="[^"]+".*>', '\[(param|member|method)?.+\]', ] + +[tool.typos.type.skip_names] +extend-glob = ["AUTHORS.md", "COPYRIGHT", "CODE_OF_CONDUCT.md", "credits.csv"] + +[tool.typos.type.skip_names.extend-identifiers] +Catylist = "Catylist" + [tool.typos.default.extend-identifiers] PNGs = "PNGs"