Skip to content

Refactor more speech functions#10593

Merged
feerrenrut merged 18 commits into
masterfrom
refactorMoreSpeechFunctions
Jan 29, 2020
Merged

Refactor more speech functions#10593
feerrenrut merged 18 commits into
masterfrom
refactorMoreSpeechFunctions

Conversation

@feerrenrut

@feerrenrut feerrenrut commented Dec 8, 2019

Copy link
Copy Markdown
Contributor

Link to issue number:

None

Summary of the issue:

Returning sequences from these functions allows us greater flexibility for affecting all speech that is caused by a call to speakObject.

Description of how this pull request fixes the issue:

Split several functions into a speakX and getXspeech

This PR maintains backwards compatibility

Testing performed:

Ran NVDA from source.

Known issues with pull request:

  • Todo: rename getSpeechForSpelling to getSpellingSpeech

Change log entry:

Section: New features, Changes, Bug fixes

@zstanecic

This comment has been minimized.

@michaelDCurran

michaelDCurran commented Dec 9, 2019 via email

Copy link
Copy Markdown
Member

@Brian1Gaff

This comment has been minimized.

@feerrenrut

Copy link
Copy Markdown
Contributor Author

@zstanecic and @Brian1Gaff This PR does not break backwards compatibility. The description has been updated to make that clear.

@feerrenrut feerrenrut force-pushed the refactorMoreSpeechFunctions branch from 400554c to a48f1e4 Compare December 9, 2019 16:14

@LeonarddeR LeonarddeR left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, however note that I only had to had time to look at the code briefly, I haven't tested this. I therefore recommend a look from @michaelDCurran before merging this.

Comment thread source/speech/__init__.py Outdated

@michaelDCurran michaelDCurran left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Would it be possible to make a new type annotation for 'reason'? All through this code you have reason: str. It would be great if this could be its own type.
  • with all the speakSelection functions: it would be good if they could take speech sequences, rather than just strings. Then speakSelectionChange can pass in a sequence from getTextInfoSpeech rather than just TextInfo.text. It also means that some of the code in speakSelectionChange can be replaced with a call to getSpellingSpeech. However, these changes would mean we can't have the text included with the message as part of one translatable string. Though I don't believe this is a bad thing.

Comment thread source/speech/__init__.py Outdated
Comment thread source/speech/__init__.py Outdated
@AppVeyorBot

Copy link
Copy Markdown
  • PR introduces Flake8 errors

See test results for failed build of commit 4ee5ba34ef

@feerrenrut feerrenrut force-pushed the refactorMoreSpeechFunctions branch from 29e56b8 to 193be74 Compare December 16, 2019 17:51
@feerrenrut feerrenrut force-pushed the refactorMoreSpeechFunctions branch from 5602078 to 582cb55 Compare December 27, 2019 17:14
@michaelDCurran

Copy link
Copy Markdown
Member

Is it just me, or have the changes to speech/__init__.py been lost in this pr?

@feerrenrut

feerrenrut commented Jan 14, 2020

Copy link
Copy Markdown
Contributor Author

Is it just me, or have the changes to speech/init.py been lost in this pr?

I think it's just you 😉. It is hidden from the diff initially because it is "large". You can jump to it, or other files by pressing 't' and typing __init__. A direct link to the file in the diff: https://github.com/nvaccess/nvda/pull/10593/files#diff-46301b9ce4a78abc208b3358db03e972

…Info

Clarify that the sequence is modified in place, nothing is spoken.
For now deprecate (but maintain) the old name.
For easier testing / refactoring.
Use instance methods directly.
Make speakWithoutPauses an instance method
- To make it more testable.
- Keep backwards compat; speakWithoutPauses name is added at module level.

Make getSpeechWithoutPauses a generator with return value.
- Speech can happen as it is generated, with the same number of calls
  to speak as previous implementation.
- Returns the same boolean values as previous implementation.
- To capture these return values, use GeneratorWithReturn class.

Add unit test for speechWithoutPauses
 - To ensure behavior has not changed between implementations
- Speech can happen as it is generated, with the same number of calls
  to speak as previous implementation.
- Returns the same boolean values as previous implementation.
- To capture these return values, use GeneratorWithReturn class.
Simplify the speakObject function by extracting this calculation into a
helper.
The new method '_objectSpeech_calculateAllowedProps()',
was extracted from 'speakObject()' and needs formatting
to pass linting checks.
Must flatten the results from getTextInfoSpeech generator.
Rename _speakPlaceholderIfEmpty -> _getPlaceholderSpeechIfTextEmpty
@feerrenrut

Copy link
Copy Markdown
Contributor Author

I'm going to rebase and merge this PR (to preserve the history of the refactor). I'll push after the rebase so that the commits in this PR / branch match.

@feerrenrut feerrenrut force-pushed the refactorMoreSpeechFunctions branch from 582cb55 to 9a884eb Compare January 29, 2020 09:01
feerrenrut added a commit that referenced this pull request Jan 29, 2020
Split several functions into two. One speakX acts as before, but relies
on a new getXspeech which returns a speech sequence.

This PR maintains backwards compatibility.

This branch is being merged to preseve history of the refactor.
Merge remote-tracking branch 'origin/refactorMoreSpeechFunctions'
@feerrenrut feerrenrut merged commit 9a884eb into master Jan 29, 2020
@feerrenrut feerrenrut deleted the refactorMoreSpeechFunctions branch January 29, 2020 09:06
@nvaccessAuto nvaccessAuto added this to the 2019.3 milestone Jan 29, 2020
feerrenrut added a commit that referenced this pull request Jan 29, 2020
@seanbudd seanbudd added the deprecated/2021.1 Label used to track deprecations due for removal in the 2021.1 release label Mar 5, 2021
seanbudd pushed a commit that referenced this pull request Mar 22, 2021
Removes code provided for backwards compatibility in PR #10593

### Summary of the issue:

PR #10593 introduced `speech.speakWithoutPauses ` as an alias for `speech._speakWithoutPauses.speakWithoutPauses` and `speech.re_last_pause` as an alias for `speech._speakWithoutPauses.re_last_pause` for backwards compatibility. Since 2021.1 is going to be backwards compatibility breaking release it makes sense to remove these.

### Description of how this pull request fixes the issue:

These aliases are removed and their usages are replaces with `speech.SpeechWithoutPauses(speakFunc=speech.speak).speakWithoutPauses` and `speech.SpeechWithoutPauses.re_last_pause` respectively.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deprecated/2021.1 Label used to track deprecations due for removal in the 2021.1 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants