def test_language_invalid(self): self.uut = Setting('key', 'not a language') with self.assertRaisesRegexp( ValueError, 'Language `not a language` is not a valid language name or ' 'not recognized by coala.'): language(self.uut)
def create_arguments(self, filename, file, config_file, language: language = language('Python 3'), python_version: str = None, allow_untyped_functions: bool = True, allow_untyped_calls: bool = True, check_untyped_function_bodies: bool = False, strict_optional: bool = False, ): """ :param language: Set to ``Python`` or ``Python 3`` to check Python 3.x source. Use ``Python 2`` for Python 2.x. :param python_version: Set the specific Python version, e.g. ``3.5``. """ args = ['-m', 'mypy'] if 'python 2' in language: args.append('--py2') elif 'python 3' not in language: # Ideally, this would fail the check, but there's no good # way to fail from create_arguments. # See https://github.com/coala/coala/issues/2573 self.err( 'Language needs to be "Python", "Python 2" or "Python 3". ' 'Assuming Python 3.') if python_version: args.extend(['--python-version', python_version]) loc = locals() args.extend(flag.arg for name, flag in FLAG_MAP.items() if flag.want_flag(loc[name])) args.append(filename) return args
def create_arguments(self, filename, file, config_file, language: language=language('Python 3'), python_version: str=None, allow_untyped_functions: bool=True, allow_untyped_calls: bool=True, check_untyped_function_bodies: bool=False, strict_optional: bool=False): """ :param language: Set to ``Python`` or ``Python 3`` to check Python 3.x source. Use ``Python 2`` for Python 2.x. :param python_version: Set the specific Python version, e.g. ``3.5``. """ args = ['-m', 'mypy'] if 'python 2' in language: args.append('--py2') elif 'python 3' not in language: # Ideally, this would fail the check, but there's no good # way to fail from create_arguments. # See https://github.com/coala/coala/issues/2573 self.err( 'Language needs to be "Python", "Python 2" or "Python 3". ' 'Assuming Python 3.') if python_version: args.extend(['--python-version', python_version]) loc = locals() args.extend(flag.arg for name, flag in FLAG_MAP.items() if flag.want_flag(loc[name])) args.append(filename) return args
def create_arguments( self, filename, file, config_file, eslint_config: str = '', language: language = language('JavaScript'), global_vars: typed_list(str) = (), eslint_env: typed_list(str) = (), ): """ :param eslint_config: The location of the .eslintrc config file. """ args = ( '--no-ignore', '--no-color', '-f=json', '--stdin', '--stdin-filename=' + filename, ) if 'Markdown' in language: args += ( '--plugin', 'markdown', ) elif 'Typescript' in language: args += ('--parser', 'typescript-eslint-parser', '--plugin', 'typescript') elif 'HTML' in language: args += ('--plugin', 'html') elif 'Javascript' not in language: self.err('Language needs to be either Markdown, HTML, TypeScript ' 'or JavaScript. Assuming JavaScript.') if eslint_env: for env in eslint_env: args += ('--env', env) if global_vars: for var in global_vars: args += ('--global', var) if eslint_config: args += ('--config', eslint_config) else: args += ('--config', config_file) return args
def create_arguments(self, filename, file, config_file, eslint_config: str = '', language: language = language('JavaScript'), global_vars: typed_list(str) = (), eslint_env: typed_list(str) = (), ): """ :param eslint_config: The location of the .eslintrc config file. """ args = ( '--no-ignore', '--no-color', '-f=json', '--stdin', '--stdin-filename=' + filename, ) if 'Markdown' in language: args += ('--plugin', 'markdown',) elif 'Typescript' in language: args += ('--parser', 'typescript-eslint-parser', '--plugin', 'typescript') elif 'HTML' in language: args += ('--plugin', 'html') elif 'Javascript' not in language: self.err( 'Language needs to be either Markdown, HTML, TypeScript ' 'or JavaScript. Assuming JavaScript.') if eslint_env: for env in eslint_env: args += ('--env', env) if global_vars: for var in global_vars: args += ('--global', var) if eslint_config: args += ('--config', eslint_config) else: args += ('--config', config_file) return args
def run(self, language: language = language('Python 3.4')): yield language
def test_language(self): self.uut = Setting('key', 'python 3.4') result = language(self.uut) self.assertIsInstance(result, Language) self.assertEqual(str(result), 'Python 3.4')