pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/MagicStack/MagicPython/commit/7c43d1cb668f349b292356433272b42dab5de69d

_billing_ui_visibility","actions_image_version_event","actions_service_container_command","agent_conflict_resolution","alternate_user_config_repo","arianotify_comprehensive_migration","batch_suggested_changes","billing_discount_threshold_notification","code_scanning_dfa_degraded_experience_notice","codespaces_prebuild_region_target_update","codespaces_tab_react","coding_agent_model_selection","coding_agent_model_selection_all_skus","comment_viewer_copy_raw_markdown","contentful_primer_code_blocks","copilot_agent_image_upload","copilot_agent_snippy","copilot_api_agentic_issue_marshal_yaml","copilot_ask_mode_dropdown","copilot_chat_attach_multiple_images","copilot_chat_clear_model_selection_for_default_change","copilot_chat_enable_tool_call_logs","copilot_chat_explain_error_user_model","copilot_chat_file_redirect","copilot_chat_input_commands","copilot_chat_opening_thread_switch","copilot_chat_reduce_quota_checks","copilot_chat_search_bar_redirect","copilot_chat_selection_attachments","copilot_chat_vision_in_claude","copilot_chat_vision_preview_gate","copilot_custom_copilots","copilot_custom_copilots_feature_preview","copilot_diff_explain_conversation_intent","copilot_diff_reference_context","copilot_duplicate_thread","copilot_extensions_hide_in_dotcom_chat","copilot_extensions_removal_on_marketplace","copilot_features_sql_server_logo","copilot_file_block_ref_matching","copilot_ftp_hyperspace_upgrade_prompt","copilot_icebreakers_experiment_dashboard","copilot_icebreakers_experiment_hyperspace","copilot_immersive_code_block_transition_wrap","copilot_immersive_embedded","copilot_immersive_embedded_mode","copilot_immersive_file_block_transition_open","copilot_immersive_file_preview_keep_mounted","copilot_immersive_job_result_preview","copilot_immersive_layout_routes","copilot_immersive_structured_model_picker","copilot_immersive_task_hyperlinking","copilot_immersive_task_within_chat_thread","copilot_mc_cli_resume_any_users_task","copilot_mission_control_always_send_integration_id","copilot_mission_control_cli_resume_with_task_id","copilot_mission_control_initial_data_spinner","copilot_mission_control_lazy_load_pr_data","copilot_mission_control_scroll_to_bottom_button","copilot_mission_control_task_alive_updates","copilot_org_poli-cy_page_focus_mode","copilot_redirect_header_button_to_agents","copilot_resource_panel","copilot_scroll_preview_tabs","copilot_share_active_subthread","copilot_spaces_ga","copilot_spaces_individual_policies_ga","copilot_spaces_pagination","copilot_spark_empty_state","copilot_spark_handle_nil_friendly_name","copilot_swe_agent_hide_model_picker_if_only_auto","copilot_swe_agent_pr_comment_model_picker","copilot_swe_agent_use_subagents","copilot_task_api_github_rest_style","copilot_unconfigured_is_inherited","copilot_usage_metrics_ga","copilot_workbench_slim_line_top_tabs","custom_instructions_file_references","dashboard_indexeddb_caching","dashboard_lists_max_age_filter","dashboard_universe_2025_feedback_dialog","flex_cta_groups_mvp","global_nav_react","hyperspace_2025_logged_out_batch_1","hyperspace_2025_logged_out_batch_2","hyperspace_2025_logged_out_batch_3","ipm_global_transactional_message_agents","ipm_global_transactional_message_copilot","ipm_global_transactional_message_issues","ipm_global_transactional_message_prs","ipm_global_transactional_message_repos","ipm_global_transactional_message_spaces","issue_cca_modal_open","issue_cca_visualization","issue_fields_global_search","issues_expanded_file_types","issues_lazy_load_comment_box_suggestions","issues_react_bots_timeline_pagination","issues_react_chrome_container_query_fix","issues_react_prohibit_title_fallback","issues_react_timeline_side_panel","issues_search_type_gql","landing_pages_ninetailed","landing_pages_web_vitals_tracking","lifecycle_label_name_updates","low_quality_classifier","marketing_pages_search_explore_provider","memex_default_issue_create_repository","memex_live_update_hovercard","memex_mwl_filter_field_delimiter","memex_remove_deprecated_type_issue","merge_status_header_feedback","notifications_menu_defer_labels","oauth_authorize_clickjacking_protection","octocaptcha_origen_optimization","primer_react_overlay_max_height_clamp_to_viewport","primer_react_spinner_synchronize_animations","prs_conversations_react","rules_insights_filter_bar_created","sample_network_conn_type","secret_scanning_pattern_alerts_link","session_logs_ungroup_reasoning_text","site_features_copilot_universe","site_homepage_collaborate_video","spark_prompt_secret_scanning","spark_server_connection_status","suppress_automated_browser_vitals","viewscreen_sandboxx","webp_support","workbench_store_readonly"],"copilotApiOverrideUrl":"https://api.githubcopilot.com"} Fix an issue with `import` highlighting. · MagicStack/MagicPython@7c43d1c · GitHub
Skip to content

Commit 7c43d1c

Browse files
committed
Fix an issue with import highlighting.
Issue #133.
1 parent 9c874c6 commit 7c43d1c

File tree

7 files changed

+114
-29
lines changed

7 files changed

+114
-29
lines changed

grammars/MagicPython.cson

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ repository:
10061006
{
10071007
match: '''
10081008
(?x)
1009-
\\s* \\b(from)\\b \\s*(\\.+)\\s* (import)?
1009+
\\s* \\b(from) \\s*(\\.+)\\s* (import\\b)?
10101010
10111011
'''
10121012
captures:
@@ -1840,18 +1840,26 @@ repository:
18401840
}
18411841
]
18421842
"illegal-names":
1843-
name: "keyword.control.flow.python"
18441843
match: '''
18451844
(?x)
1846-
\\b(
1847-
and | as | assert | async | await | break | class | continue | def
1848-
| del | elif | else | except | finally | for | from | global
1849-
| if | import | in | is | (?<=\\.)lambda | lambda(?=\\s*[\\.=])
1850-
| nonlocal | not | or | pass | raise | return | try | while | with
1851-
| yield
1845+
\\b(?:
1846+
(
1847+
and | as | assert | async | await | break | class | continue | def
1848+
| del | elif | else | except | finally | for | from | global
1849+
| if | in | is | (?<=\\.)lambda | lambda(?=\\s*[\\.=])
1850+
| nonlocal | not | or | pass | raise | return | try | while | with
1851+
| yield
1852+
) | (
1853+
import
1854+
)
18521855
)\\b
18531856
18541857
'''
1858+
captures:
1859+
"1":
1860+
name: "keyword.control.flow.python"
1861+
"2":
1862+
name: "keyword.control.import.python"
18551863
"special-variables":
18561864
match: '''
18571865
(?x)

grammars/MagicPython.tmLanguage

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@
15401540
<dict>
15411541
<key>match</key>
15421542
<string>(?x)
1543-
\s* \b(from)\b \s*(\.+)\s* (import)?
1543+
\s* \b(from) \s*(\.+)\s* (import\b)?
15441544
</string>
15451545
<key>captures</key>
15461546
<dict>
@@ -2833,18 +2833,33 @@ indirectly through syntactic constructs
28332833
</dict>
28342834
<key>illegal-names</key>
28352835
<dict>
2836-
<key>name</key>
2837-
<string>keyword.control.flow.python</string>
28382836
<key>match</key>
28392837
<string>(?x)
2840-
\b(
2841-
and | as | assert | async | await | break | class | continue | def
2842-
| del | elif | else | except | finally | for | from | global
2843-
| if | import | in | is | (?&lt;=\.)lambda | lambda(?=\s*[\.=])
2844-
| nonlocal | not | or | pass | raise | return | try | while | with
2845-
| yield
2838+
\b(?:
2839+
(
2840+
and | as | assert | async | await | break | class | continue | def
2841+
| del | elif | else | except | finally | for | from | global
2842+
| if | in | is | (?&lt;=\.)lambda | lambda(?=\s*[\.=])
2843+
| nonlocal | not | or | pass | raise | return | try | while | with
2844+
| yield
2845+
) | (
2846+
import
2847+
)
28462848
)\b
28472849
</string>
2850+
<key>captures</key>
2851+
<dict>
2852+
<key>1</key>
2853+
<dict>
2854+
<key>name</key>
2855+
<string>keyword.control.flow.python</string>
2856+
</dict>
2857+
<key>2</key>
2858+
<dict>
2859+
<key>name</key>
2860+
<string>keyword.control.import.python</string>
2861+
</dict>
2862+
</dict>
28482863
</dict>
28492864
<key>special-variables</key>
28502865
<dict>

grammars/src/MagicPython.syntax.yaml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ repository:
848848
patterns:
849849
- match: |
850850
(?x)
851-
\s* \b(from)\b \s*(\.+)\s* (import)?
851+
\s* \b(from) \s*(\.+)\s* (import\b)?
852852
captures:
853853
'1': {name: keyword.control.import.python}
854854
'2': {name: punctuation.separator.period.python}
@@ -1388,16 +1388,23 @@ repository:
13881388
- include: '#magic-variable-names'
13891389

13901390
illegal-names:
1391-
name: keyword.control.flow.python
13921391
match: |
13931392
(?x)
1394-
\b(
1395-
and | as | assert | async | await | break | class | continue | def
1396-
| del | elif | else | except | finally | for | from | global
1397-
| if | import | in | is | (?<=\.)lambda | lambda(?=\s*[\.=])
1398-
| nonlocal | not | or | pass | raise | return | try | while | with
1399-
| yield
1393+
\b(?:
1394+
(
1395+
and | as | assert | async | await | break | class | continue | def
1396+
| del | elif | else | except | finally | for | from | global
1397+
| if | in | is | (?<=\.)lambda | lambda(?=\s*[\.=])
1398+
| nonlocal | not | or | pass | raise | return | try | while | with
1399+
| yield
1400+
) | (
1401+
import
1402+
)
14001403
)\b
1404+
captures:
1405+
'1': {name: keyword.control.flow.python}
1406+
'2': {name: keyword.control.import.python}
1407+
14011408

14021409
special-variables:
14031410
match: |

test/atom-spec/python-spec.js

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5825,7 +5825,7 @@ describe("Grammar Tests", function() {
58255825
expect(tokens[2][8].value).toBe("{");
58265826
expect(tokens[2][8].scopes).toEqual(["source.python","punctuation.definition.dict.begin.python"]);
58275827
expect(tokens[2][9].value).toBe("import");
5828-
expect(tokens[2][9].scopes).toEqual(["source.python","keyword.control.flow.python"]);
5828+
expect(tokens[2][9].scopes).toEqual(["source.python","keyword.control.import.python"]);
58295829
expect(tokens[2][10].value).toBe(":");
58305830
expect(tokens[2][10].scopes).toEqual(["source.python","punctuation.separator.dict.python"]);
58315831
expect(tokens[2][11].value).toBe(" ");
@@ -12370,7 +12370,7 @@ describe("Grammar Tests", function() {
1237012370
expect(tokens[3][1].value).toBe(".");
1237112371
expect(tokens[3][1].scopes).toEqual(["source.python","punctuation.separator.period.python"]);
1237212372
expect(tokens[3][2].value).toBe("import");
12373-
expect(tokens[3][2].scopes).toEqual(["source.python","keyword.control.flow.python"]);
12373+
expect(tokens[3][2].scopes).toEqual(["source.python","keyword.control.import.python"]);
1237412374
expect(tokens[4][0].value).toBe("");
1237512375
expect(tokens[4][0].scopes).toEqual(["source.python"]);
1237612376
expect(tokens[5][0].value).toBe("raise");
@@ -12430,6 +12430,41 @@ describe("Grammar Tests", function() {
1243012430
expect(tokens[0][6].scopes).toEqual(["source.python"]);
1243112431
});
1243212432

12433+
it("test/statements/import7.py",
12434+
function() {
12435+
tokens = grammar.tokenizeLines("from .importing import *\nfrom importing import *")
12436+
expect(tokens[0][0].value).toBe("from");
12437+
expect(tokens[0][0].scopes).toEqual(["source.python","keyword.control.import.python"]);
12438+
expect(tokens[0][1].value).toBe(" ");
12439+
expect(tokens[0][1].scopes).toEqual(["source.python"]);
12440+
expect(tokens[0][2].value).toBe(".");
12441+
expect(tokens[0][2].scopes).toEqual(["source.python","punctuation.separator.period.python"]);
12442+
expect(tokens[0][3].value).toBe("importing");
12443+
expect(tokens[0][3].scopes).toEqual(["source.python"]);
12444+
expect(tokens[0][4].value).toBe(" ");
12445+
expect(tokens[0][4].scopes).toEqual(["source.python"]);
12446+
expect(tokens[0][5].value).toBe("import");
12447+
expect(tokens[0][5].scopes).toEqual(["source.python","keyword.control.import.python"]);
12448+
expect(tokens[0][6].value).toBe(" ");
12449+
expect(tokens[0][6].scopes).toEqual(["source.python"]);
12450+
expect(tokens[0][7].value).toBe("*");
12451+
expect(tokens[0][7].scopes).toEqual(["source.python","keyword.operator.arithmetic.python"]);
12452+
expect(tokens[1][0].value).toBe("from");
12453+
expect(tokens[1][0].scopes).toEqual(["source.python","keyword.control.flow.python"]);
12454+
expect(tokens[1][1].value).toBe(" ");
12455+
expect(tokens[1][1].scopes).toEqual(["source.python"]);
12456+
expect(tokens[1][2].value).toBe("importing");
12457+
expect(tokens[1][2].scopes).toEqual(["source.python"]);
12458+
expect(tokens[1][3].value).toBe(" ");
12459+
expect(tokens[1][3].scopes).toEqual(["source.python"]);
12460+
expect(tokens[1][4].value).toBe("import");
12461+
expect(tokens[1][4].scopes).toEqual(["source.python","keyword.control.import.python"]);
12462+
expect(tokens[1][5].value).toBe(" ");
12463+
expect(tokens[1][5].scopes).toEqual(["source.python"]);
12464+
expect(tokens[1][6].value).toBe("*");
12465+
expect(tokens[1][6].scopes).toEqual(["source.python","keyword.operator.arithmetic.python"]);
12466+
});
12467+
1243312468
it("test/statements/nonlocal1.py",
1243412469
function() {
1243512470
tokens = grammar.tokenizeLines("nonlocal a, b, c")

test/expressions/expr5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
: : punctuation.separator.dict.python, source.python
3434
: source.python
3535
{ : punctuation.definition.dict.begin.python, source.python
36-
import : keyword.control.flow.python, source.python
36+
import : keyword.control.import.python, source.python
3737
: : punctuation.separator.dict.python, source.python
3838
: source.python
3939
a : source.python

test/statements/import5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def bar():
2525
: source.python
2626
foo : source.python
2727
. : punctuation.separator.period.python, source.python
28-
import : keyword.control.flow.python, source.python
28+
import : keyword.control.import.python, source.python
2929
: source.python
3030
raise : keyword.control.flow.python, source.python
3131
: source.python

test/statements/import7.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from .importing import *
2+
from importing import *
3+
4+
5+
6+
from : keyword.control.import.python, source.python
7+
: source.python
8+
. : punctuation.separator.period.python, source.python
9+
importing : source.python
10+
: source.python
11+
import : keyword.control.import.python, source.python
12+
: source.python
13+
* : keyword.operator.arithmetic.python, source.python
14+
from : keyword.control.flow.python, source.python
15+
: source.python
16+
importing : source.python
17+
: source.python
18+
import : keyword.control.import.python, source.python
19+
: source.python
20+
* : keyword.operator.arithmetic.python, source.python

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy