-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add a decorator to warn on wrong file extension #2573
base: master
Are you sure you want to change the base?
Add a decorator to warn on wrong file extension #2573
Conversation
mesonbuild/interpreterbase.py
Outdated
@@ -55,6 +55,37 @@ def wrapped(self, node, args, kwargs): | |||
return f(self, node, args, kwargs) | |||
return wrapped | |||
|
|||
#This decorator does the same than permittedKwargs plus: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Flake8]
block comment should start with '# '
mesonbuild/interpreterbase.py
Outdated
for key, item in kwargs.items(): | ||
if key in self.extensions_dict: | ||
extensions = self.extensions_dict[key] | ||
if not extensions is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Flake8]
test for object identity should be 'is not'
mesonbuild/mesonlib.py
Outdated
if hasattr(s, 'held_object') or isinstance(s, File): | ||
pass | ||
elif isinstance(s, str): | ||
# self.validate_within_subproject(self.subdir, s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Flake8]
indentation is not a multiple of four (comment)
mesonbuild/modules/qt.py
Outdated
@@ -19,7 +19,7 @@ | |||
from ..dependencies import Qt4Dependency, Qt5Dependency | |||
import xml.etree.ElementTree as ET | |||
from . import ModuleReturnValue, get_include_args | |||
from ..interpreterbase import permittedKwargs | |||
from ..interpreterbase import permittedKwargs, processArgs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Flake8]
'..interpreterbase.permittedKwargs' imported but unused
53af3c8
to
6916f03
Compare
I've also added string to File conversion in this decorator, this would help modules to use File everywhere. |
Flake8 detected 9 issues on ae3f246 |
a72adcf
to
6dbcdbf
Compare
6dbcdbf
to
f1f3b4a
Compare
I don't like the fact that this reduces readability. Decorators can be stacked on top of each other without problems, see for example |
I agree the name sucks. But stacking decorators has few drawbacks:
|
Any module can use this decorator to warn the user if he passes wrong files to the method based on their extension. source_strings_to_files, validate_within_subproject and evaluate_subproject_info are now part of mesonlib.
f1f3b4a
to
33a5352
Compare
see #2438 (comment) I'm not a python ninja, but let me know if i can help out somehow. |
I guess if this is still desirable, it should be redone to be an attribute of a KwargInfo object? |
Yeah, probably. |
Any module can use this decorator to warn the user if he passes
wrong files to the method based on their extension.
This reimplements #2565 in a more generic way.