exclude entities from standard naming linter rule#2793
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2793 +/- ##
==========================================
- Coverage 82.99% 82.98% -0.02%
==========================================
Files 126 126
Lines 13993 13994 +1
Branches 3908 3903 -5
==========================================
- Hits 11614 11613 -1
- Misses 1730 1731 +1
- Partials 649 650 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
pkalita-lbl
left a comment
There was a problem hiding this comment.
Looks good!
Not necessary for right now, but a thought for later: if we find other rules that might be excludable or includable by element name or type we should think about abstracting the exclude, exclude_type, etc attributes out into mixins.
| messages = [p.message for p in problems] | ||
| assert "Class has name 'another_bad_class'" in messages | ||
| assert "Slot has name 'AnotherBadSlot'" in messages | ||
| assert "Enum has name 'another_bad_enum'" in messages |
There was a problem hiding this comment.
It might be easier to do the following for the tests:
expected_messages = {
"Class has name 'another_bad_class'",
"Slot has name 'AnotherBadSlot'",
"Enum has name 'another_bad_enum'",
"Permissible value of Enum 'GoodEnum' has name 'Extra_Bad_Pv'"
}
assert {p.message for p in problems} == expected_messagesThe "not" assertions are automatically tested.
83ef61b to
6eb611a
Compare
Added clear examples of names that would fail validation and need exclusion: - "legacy_class" (class name in snake_case instead of UpperCamel) - "badSlot" (slot name in camelCase instead of snake_case) - "bad_enum" (enum name in snake_case instead of UpperCamel) - "LEGACY_PERMISSIBLE_VALUE" (permissible value in UPPER_SNAKE when snake_case expected) Addresses feedback from @ialarmedalien requesting concrete examples. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
The config.py file is auto-generated from config.yaml via the Makefile. Previous manual edits to config.py would have been lost on next generation. Now properly regenerated to include the updated exclude field documentation. Addresses feedback from @ialarmedalien about config.py being auto-generated. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Changes based on @ialarmedalien's feedback: - Added "Extra_Bad_Pv" as additional bad permissible value to test exclusion - Replaced individual assert statements with cleaner set-based comparison - The set approach automatically tests both positive and negative cases - More concise and maintainable test structure 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Pre-commit hooks automatically fixed: - Deprecated typing.Dict/List imports in auto-generated config.py - Line length violation in test file (broke long comment into multiple lines) - Missing newline at end of config.py file 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Implemented @ialarmedalien's suggested refactoring: - Consolidated patterns into a dictionary indexed by element type - Used list comprehensions and generator expressions for cleaner logic - Eliminated repetitive if/for loops for classes, slots, and enums - More maintainable and easier to understand code structure - All tests pass - functionality unchanged The refactored approach uses data structures and loops instead of repetitive conditional blocks, making the code much more concise. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Auto-generated linkml/linter/config/datamodel/config.py uses older typing patterns (Dict/List) that violate UP035 rule. Since this file is generated by gen-python, the issue is upstream in the LinkML Python generator. Added UP035 to per-file-ignores to prevent CI failures on generated code. This is a pragmatic solution until the generator is updated. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Replace list comprehensions with generator expressions for better memory efficiency - Use explicit method mapping dictionary instead of getattr() for better readability - Chain generators with itertools.chain() instead of extending lists - Maintain same functionality while improving performance and code clarity 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Rename schema_methods to element_extractors for clarity - Cache method results to avoid repeated function calls during iteration - Return iter(problems) for consistent generator behavior in both code paths - Maintain all functionality while improving performance and code clarity 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull Request Overview
This PR adds functionality to exclude specific named entities from the standard naming linter rule by introducing a new exclude configuration option. This allows users to skip naming validation for specific classes, slots, enums, and permissible values by name.
Key changes:
- Added new
excludeconfiguration parameter to skip named entities from linting - Refactored the StandardNamingRule check method to use a more efficient generator-based approach
- Updated auto-generated configuration files and linter exclusions
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
linkml/linter/config/datamodel/config.yaml |
Added new exclude field definition to the StandardNamingConfig schema |
linkml/linter/config/datamodel/config.py |
Auto-generated configuration class with new exclude field and validation logic |
linkml/linter/rules.py |
Refactored StandardNamingRule to support entity exclusion by name and improved efficiency |
tests/test_linter/test_rule_standard_naming.py |
Added comprehensive test cases for the new exclude functionality |
pyproject.toml |
Updated linter configuration to exclude auto-generated files and added UP035 rule exception |
| "linkml/generators/sqlalchemy/sqlalchemy_declarative_template.py" = ["E501"] | ||
| "linkml/generators/sqlalchemy/sqlalchemy_imperative_template.py" = ["E501"] | ||
| "linkml/linter/config/datamodel/config.py" = ["E501", "F401", "I001"] | ||
| "linkml/linter/config/datamodel/config.py" = ["E501", "F401", "I001", "UP035"] |
There was a problem hiding this comment.
the python generator uses old-style type hints but our linter doesn't like that
No description provided.