Comments (2)
Hello, @stsmrvestas! Thanks for reaching out!
The error message you are seeing here actually comes from our YAML parser. Because of the YAML syntax, our parser (correctly) interprets the line pattern: class ${klass}:
as if you were building a nested dictionary {"pattern": {"class ${klass}": ""}}
. Strange, right?
To fix this, you can use a multiline YAML string:
rules:
- id: service-class-naming
description: Service class naming convention
pattern: |
class ${klass}(...):
...
condition: not klass.ends_with("Service")
explanation: 'Service classes must be postfixed with "Service" - if you have additional classes in the same file, please move them to a separate file'
I have also fixed the Sourcery pattern syntax for you by using the universal matcher ...
and simplified the matching condition by using the ends_with
conditional, which (I think?) is what your rule is about.
Please let me know if this does (or does not) work for you.
from sourcery.
Thanks - that works.
I think I was thrown by a couple of things:
- I need to include the '...' aka class body - it is not sufficient to simply do a single line even if I don't care about the body of the class - that's prolly how it has to be, but not 100% intuitive..
- the tests also needs to follow the same rule (class body required)
- Your suggestion doesn't take into appear to take into account when the classes are like this:
class SomeClass: # no parenthesis
...
but even with your proposal, the above example actually works and detects that SomeClass does not end with Service even though it doesn't strictly match the 'class ${klass}(...):' pattern which has the parenthesis.
This last thing is what I want, but it is not clear why it actually works, and I would never have guess this?
Anyways thanks for the assistance!
from sourcery.
Related Issues (20)
- Sourcery doesn't recognise Jetbrains 'remote development' WSL project as open source HOT 1
- Project disabled for account due to open source account. I have a pro account HOT 1
- FIX Cannot select and copy that text in Sourcery sidebar HOT 3
- The "CI" link is incorrect HOT 2
- Remaining manual issues should be listed separately from autofixed ones HOT 1
- Sourcery seems to hate anything Linux related? HOT 1
- Incorrect structure when generating docstrings HOT 2
- After upgrading to Pro Plan the VsCode Extension still identifies me as being on the Open-source Plan HOT 2
- VS Code: Couldn't create connection to server to Sourcery at startup HOT 2
- docstrings style
- MacOs PyCharm Plugin stuck at "Loading" HOT 2
- Implement "Generate Docstring" & "Generate Test Cases" in CLI and Neovim
- review doesn't work on organization's repo HOT 4
- PyCharm plugin freezes - restart possible? HOT 2
- It should review changed files, not original. HOT 1
- Sourcery GitHub app returns no status if no refactorings have been found HOT 1
- Sourcery plugin not working for Pycharm HOT 4
- feat: review should be updated or create a new one. HOT 5
- Sourcery incorrectly skips re-reviewing PR HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sourcery.