Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Add support for PEP701 #656

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

parona-source
Copy link
Contributor

@parona-source parona-source commented Nov 1, 2023

  • fstrings are broken into several distinct tokens in py3.12, reattach
    them together as a singular string to preserve previous behavior.

Closes: #646

  • Add unit tests and integration tests where applicable.
    If you've added an error code or changed an error code behavior,
    you should probably add or change a test case file under tests/test_cases/ and add
    it to the list under tests/test_definitions.py.
    If you've added or changed a command line option,
    you should probably add or change a test in tests/test_integration.py.
  • Add a line to the release notes (docs/release_notes.rst) under "Current Development Version".
    Make sure to include the PR number after you open and get one.

@parona-source parona-source force-pushed the pep701 branch 2 times, most recently from ae9147d to ea10780 Compare November 1, 2023 09:31
@parona-source

This comment was marked as resolved.

@parona-source

This comment was marked as outdated.

@parona-source
Copy link
Contributor Author

python3.12 -m tokenize <(echo 'f"""Do something. {f"This is a nested fstring."}"""')
0,0-0,0:            ENCODING       'utf-8'        
1,0-1,4:            FSTRING_START  'f"""'         
1,4-1,18:           FSTRING_MIDDLE 'Do something. '
1,18-1,19:          OP             '{'            
1,19-1,21:          FSTRING_START  'f"'           
1,21-1,46:          FSTRING_MIDDLE 'This is a nested fstring.'
1,46-1,47:          FSTRING_END    '"'            
1,47-1,48:          OP             '}'            
1,48-1,51:          FSTRING_END    '"""'          
1,51-1,52:          NEWLINE        '\n'           
2,0-2,0:            ENDMARKER      ''  
python3.11 -m tokenize <(echo 'f"""Do something. {f"This is a nested fstring."}"""')
0,0-0,0:            ENCODING       'utf-8'        
1,0-1,51:           STRING         'f"""Do something. {f"This is a nested fstring."}"""'
1,51-1,52:          NEWLINE        '\n'           
2,0-2,0:            ENDMARKER      ''

@parona-source parona-source marked this pull request as ready for review November 2, 2023 08:16
* fstrings are broken into several distinct tokens in py3.12, reattach
  them together as a singular string to preserve previous behavior.

Closes: PyCQA#646
Signed-off-by: Alfred Wingate <parona@protonmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test_simple_fstring and test_fstring_with_args fail with Python 3.12 beta
1 participant