typing: Fix templates

pull/7657/head
Daniel Mensinger 4 years ago
parent 62f7642a61
commit 1b19822a2d
No known key found for this signature in database
GPG Key ID: 54DD94C131E277D4
  1. 4
      mesonbuild/templates/cpptemplates.py
  2. 4
      mesonbuild/templates/cstemplates.py
  3. 4
      mesonbuild/templates/ctemplates.py
  4. 4
      mesonbuild/templates/cudatemplates.py
  5. 4
      mesonbuild/templates/dlangtemplates.py
  6. 4
      mesonbuild/templates/fortrantemplates.py
  7. 4
      mesonbuild/templates/javatemplates.py
  8. 4
      mesonbuild/templates/mesontemplates.py
  9. 4
      mesonbuild/templates/objcpptemplates.py
  10. 4
      mesonbuild/templates/objctemplates.py
  11. 4
      mesonbuild/templates/rusttemplates.py
  12. 4
      mesonbuild/templates/samplefactory.py
  13. 4
      mesonbuild/templates/sampleimpl.py

@ -146,7 +146,7 @@ class CppProject(SampleImpl):
self.name = options.name
self.version = options.version
def create_executable(self):
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
source_name = lowercase_token + '.cpp'
open(source_name, 'w').write(hello_cpp_template.format(project_name=self.name))
@ -155,7 +155,7 @@ class CppProject(SampleImpl):
source_name=source_name,
version=self.version))
def create_library(self):
def create_library(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
uppercase_token = lowercase_token.upper()
class_name = uppercase_token[0] + lowercase_token[1:]

@ -95,7 +95,7 @@ class CSharpProject(SampleImpl):
self.name = options.name
self.version = options.version
def create_executable(self):
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
uppercase_token = lowercase_token.upper()
class_name = uppercase_token[0] + lowercase_token[1:]
@ -107,7 +107,7 @@ class CSharpProject(SampleImpl):
source_name=source_name,
version=self.version))
def create_library(self):
def create_library(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
uppercase_token = lowercase_token.upper()
class_name = uppercase_token[0] + lowercase_token[1:]

@ -129,7 +129,7 @@ class CProject(SampleImpl):
self.name = options.name
self.version = options.version
def create_executable(self):
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
source_name = lowercase_token + '.c'
open(source_name, 'w').write(hello_c_template.format(project_name=self.name))
@ -138,7 +138,7 @@ class CProject(SampleImpl):
source_name=source_name,
version=self.version))
def create_library(self):
def create_library(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
uppercase_token = lowercase_token.upper()
function_name = lowercase_token[0:3] + '_func'

@ -146,7 +146,7 @@ class CudaProject(SampleImpl):
self.name = options.name
self.version = options.version
def create_executable(self):
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
source_name = lowercase_token + '.cu'
open(source_name, 'w').write(hello_cuda_template.format(project_name=self.name))
@ -155,7 +155,7 @@ class CudaProject(SampleImpl):
source_name=source_name,
version=self.version))
def create_library(self):
def create_library(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
uppercase_token = lowercase_token.upper()
class_name = uppercase_token[0] + lowercase_token[1:]

@ -107,7 +107,7 @@ class DlangProject(SampleImpl):
self.name = options.name
self.version = options.version
def create_executable(self):
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
source_name = lowercase_token + '.d'
open(source_name, 'w').write(hello_d_template.format(project_name=self.name))
@ -116,7 +116,7 @@ class DlangProject(SampleImpl):
source_name=source_name,
version=self.version))
def create_library(self):
def create_library(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
uppercase_token = lowercase_token.upper()
function_name = lowercase_token[0:3] + '_func'

@ -106,7 +106,7 @@ class FortranProject(SampleImpl):
self.name = options.name
self.version = options.version
def create_executable(self):
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
source_name = lowercase_token + '.f90'
open(source_name, 'w').write(hello_fortran_template.format(project_name=self.name))
@ -115,7 +115,7 @@ class FortranProject(SampleImpl):
source_name=source_name,
version=self.version))
def create_library(self):
def create_library(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
uppercase_token = lowercase_token.upper()
function_name = lowercase_token[0:3] + '_func'

@ -99,7 +99,7 @@ class JavaProject(SampleImpl):
self.name = options.name
self.version = options.version
def create_executable(self):
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
uppercase_token = lowercase_token.upper()
class_name = uppercase_token[0] + lowercase_token[1:]
@ -111,7 +111,7 @@ class JavaProject(SampleImpl):
source_name=source_name,
version=self.version))
def create_library(self):
def create_library(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
uppercase_token = lowercase_token.upper()
class_name = uppercase_token[0] + lowercase_token[1:]

@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
meson_executable_template = '''project('{project_name}', '{language}',
version : '{version}',
default_options : [{default_options}])
@ -33,7 +35,7 @@ jar('{executable}',
'''
def create_meson_build(options):
def create_meson_build(options: argparse.Namespace) -> None:
if options.type != 'executable':
raise SystemExit('\nGenerating a meson.build file from existing sources is\n'
'supported only for project type "executable".\n'

@ -129,7 +129,7 @@ class ObjCppProject(SampleImpl):
self.name = options.name
self.version = options.version
def create_executable(self):
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
source_name = lowercase_token + '.mm'
open(source_name, 'w').write(hello_objcpp_template.format(project_name=self.name))
@ -138,7 +138,7 @@ class ObjCppProject(SampleImpl):
source_name=source_name,
version=self.version))
def create_library(self):
def create_library(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
uppercase_token = lowercase_token.upper()
function_name = lowercase_token[0:3] + '_func'

@ -129,7 +129,7 @@ class ObjCProject(SampleImpl):
self.name = options.name
self.version = options.version
def create_executable(self):
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
source_name = lowercase_token + '.m'
open(source_name, 'w').write(hello_objc_template.format(project_name=self.name))
@ -138,7 +138,7 @@ class ObjCProject(SampleImpl):
source_name=source_name,
version=self.version))
def create_library(self):
def create_library(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
uppercase_token = lowercase_token.upper()
function_name = lowercase_token[0:3] + '_func'

@ -77,7 +77,7 @@ class RustProject(SampleImpl):
self.name = options.name
self.version = options.version
def create_executable(self):
def create_executable(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
source_name = lowercase_token + '.rs'
open(source_name, 'w').write(hello_rust_template.format(project_name=self.name))
@ -86,7 +86,7 @@ class RustProject(SampleImpl):
source_name=source_name,
version=self.version))
def create_library(self):
def create_library(self) -> None:
lowercase_token = re.sub(r'[^a-z0-9]', '_', self.name.lower())
uppercase_token = lowercase_token.upper()
function_name = lowercase_token[0:3] + '_func'

@ -21,9 +21,11 @@ from mesonbuild.templates.objctemplates import ObjCProject
from mesonbuild.templates.cpptemplates import CppProject
from mesonbuild.templates.cstemplates import CSharpProject
from mesonbuild.templates.ctemplates import CProject
from mesonbuild.templates.sampleimpl import SampleImpl
import argparse
def sameple_generator(options):
def sameple_generator(options: argparse.Namespace) -> SampleImpl:
return {
'c': CProject,
'cpp': CppProject,

@ -14,8 +14,8 @@
class SampleImpl:
def create_executable(self):
def create_executable(self) -> None:
raise NotImplementedError('Sample implementation for "executable" not implemented!')
def create_library(self):
def create_library(self) -> None:
raise NotImplementedError('Sample implementation for "library" not implemented!')

Loading…
Cancel
Save