Skip to main content

voicelint

voicelint is a pylint plug-in/extension designed to aid users of Caster,a dragonfly based toolkit for programming by voice, when writing their own grammars by catching some common or annoying mistakes.

Contents

Getting Started

In case you have never heard before,pylint is a popular static analysis tool, which can help you catch various errors and/or help you improve code quality. You can install it with pip

python3 -m pip install pylint

and can be integrated with many editors via available extensions. For instance, you can follow instructions here for VSCode and for sublime you can use SublimeLinter in combination with SublimeLinter-pylint

Once you have done that, you need to install voicelint by similarly executing

python37 -m pip install voicelint

and configure pylint to use this plug-in for our grammars!

Now the easiest way to configure pylint is via a .pylintrc file, which you should place in the root directory you interested in. For our use case, that is the rules folder of the caster user directory, so it should be something like

C:\Users\%USERNAME%\AppData\Local\caster\rules

if you're in the latest version of caster. To tell pylint to load our plug-in, we need to set the load-plugins setting, so our file should look something like

[MASTER]
load-plugins=voicelint

Now we are goot and set with that,we are now faced with a different technicality that does not have to do with our plug-in but rather linting caster grammars in general. In particular, python allows manipulating during runtime the set of directories it searches for modules import, which creates headaches for static analysis tools as they cannot know in advance which directories will be added or removed. Caster relies heavily on these feature and as a consequence pylint will complain about being unable to find the castervoice modules.

To sidestep this issue, we need to inform pylint of the directories Castor adds to the path and we can do that by adding the following lines (adjust for the paths used in your computer)

[MASTER]
init-hook='import sys; sys.path.append("C:\\Users\\%USERNAME%\\AppData\\Local\\caster\\rules"); sys.path.append("C:\\Users\\%USERNAME%\\Documents\\Github\\Caster")'

load-plugins=voicelint

and now you should be up and running!!!

Currently Recognized Errors/Mistakes

Not that many for the time being but I hope they help!

Mimic Errors

Mimic(["hello","world"]) # wrong
Mimic("hello world") # wrong

vs 

Mimic("hello","world") # `,` separated single words


Mimic(keyword_name_other_than_extra="something") # only allowed keyword is `extra` 

Pause errors

Pause(10) 

vs

Pause("10") # must be a string instead of integer 

Forgeting Conditional Import

When importing support files, 99% of the time you should be using try except blocks to allow overriding from the user directory

from castervoice.rules.apps.editor.eclipse_rules.eclipse_support import ec_con

vs

try: # Try first loading from caster user directory
    from eclipse_support import ec_con
except ImportError:    
    from castervoice.rules.apps.editor.eclipse_rules.eclipse_support import ec_con

Various Rule Details Errors

for example

class ExampleRule(MergeRule):
	blah,blah,blah


def get_rule():
	return ExampleRule,RuleDetails(ccrtype=CCRType.GLOBAL,executable="chrome")	

	vs 

	return ExampleRule,RuleDetails(ccrtype=CCRType.APP,executable="chrome")	

and many others for the current version of Caster (28/07/2020)

Key-Text-Mouse Separated strings Errors

All the key presses should be in a single string

Key("c-a","c-c")
Text("nice","day")
Mouse("[12,100]","(4,5)")
vs

Key("c-a,c-c")
Text("nice day")
Mouse("[12,100],(4,5)")

BringApp and StartApp no dynamic strings

BringApp("program","%(data)s")

vs 

Function(lambda data: BringApp('program',data.format()).execute())

License

voicelint is licensed under 2-clause BSD

BSD 2-Clause License

Copyright (c) 2020, Kitsios Panagiotis
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Metadata

Release files for voicelint 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for voicelint 0.1.0
File Size Uploaded
voicelint-0.1.0.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for voicelint 0.1.0
File Interpreter ABI Platform
voicelint-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.1 kB

Release files / voicelint-0.1.0.tar.gz

Download URL voicelint-0.1.0.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
fe2bd12fa33c28f5f17b71c7ce3e7d34ee8c61dc40d98c8998058075592370dc
BLAKE2b-256 checksum
How to use checksums
a3637ca3be674e69cf190c748faaa92a0d7475a2022f452b333494910f2b8452
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.4

Release files / voicelint-0.1.0-py3-none-any.whl

Download URL voicelint-0.1.0-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
81dbd43a754e2a74c6f820428adfaf91a89ce5da3c37995851ee547abd967fa9
BLAKE2b-256 checksum
How to use checksums
ac6b47a49be0276705d0f411eeb981dbbc67582fbe4371fca566c74240960236
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.4

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page