-
Notifications
You must be signed in to change notification settings - Fork 340
Ianhelle/msticpy 3.0 and Python 3.13 #867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ianhelle
wants to merge
42
commits into
main
Choose a base branch
from
ianhelle/py313-cleanup-2025-12-08
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+2,736
−7,385
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Updating pyautogen dependencies for Python 3.13
Fixing aiagents
with Python < 3.10
Also excluding some test functions for linux
- implementing ruff as primary linter - updating type annotations to modern format
…e/py313-cleanup-2025-12-08 # Conflicts: # msticpy/aiagents/rag_agents.py # msticpy/data/sql_to_kql.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…e/py313-cleanup-2025-12-08 # Conflicts: # msticpy/analysis/outliers.py # msticpy/init/azure_ml_tools.py
…ithub.com/microsoft/msticpy into ianhelle/update_mo_sql_parsing-2025-12-08
…e/py313-cleanup-2025-12-08
- also removing unneeded dependencies - cleaning up unit tests - removing build for Python 3.8 and 3.9 - setting version to 3.0.0.pre1
…/py313-cleanup-2025-12-08 # Conflicts: # .github/workflows/python-package.yml # conda/conda-reqs-pip.txt # msticpy/aiagents/mp_docs_rag_magic.py # msticpy/aiagents/rag_agents.py # msticpy/analysis/outliers.py # msticpy/context/tiproviders/pulsedive.py # msticpy/data/drivers/kql_driver.py # requirements-all.txt # setup.py # tests/aiagents/test_rag_agents.py
Collaborator
ryan-detect-dot-dev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only minor questions, otherwise LGTM
## Overview This commit represents a major modernization effort for MSticPy 3.0, dropping support for Python 3.8 and 3.9 to leverage modern Python features and clean up technical debt. ## Breaking Changes ### Python Version Requirements - **Minimum Python version raised from 3.8 to 3.10** - Updated in `setup.cfg`: `python_requires = >=3.10` - Updated build target in `pyproject.toml`: `target-version = "py310"` - Removed Python version-specific conditionals from requirements files ### Dependency Cleanup - Removed `importlib-resources` (only needed for Python ≤3.8) - Simplified `ipython` dependency (removed version-specific conditionals) - Removed outdated conditional dependencies from: - `requirements.txt` - `requirements-all.txt` - `conda/conda-reqs-pip.txt` - `conda/conda-reqs-dev.txt` ## Code Quality Improvements ### Type Hint Modernization - Replaced legacy `typing.Union` with modern `|` union syntax (PEP 604) - Replaced `typing.Optional` with `| None` where appropriate - Updated type hints across 300+ files for improved readability ### Code Style and Linting - Updated `.pylintrc`: max line length reduced from 110 to 95 characters - Enhanced `pyproject.toml` with comprehensive Ruff configuration: - Line length: 95 characters (consistent with pylint) - Target version: Python 3.10 - Enabled rule sets: pycodestyle, pyflakes, isort, pydocstyle, pyupgrade, flake8-bugbear - Configured numpy-style docstring convention - Updated `.pre-commit-config.yaml` with modern linting tools ## Deprecated Code Removal ### AI Agents Module Removed entire `msticpy/aiagents/` module (deprecated functionality): - `config_utils.py` - `mp_docs_rag_magic.py` - `rag_agents.py` - Associated test file `tests/aiagents/test_rag_agents.py` ### Legacy Data Drivers Removed deprecated and obsolete driver files: - `msticpy/data/drivers/kql_driver.py` (587 lines removed) - `msticpy/data/drivers/kusto_driver.py` (296 lines removed) - Associated test files: - `tests/data/drivers/test_kql_driver.py` - `tests/data/drivers/test_kusto_driver.py` ### Deprecated Aliases and Shims Removed compatibility shims and deprecated module aliases: - `msticpy/common/azure_auth.py` - `msticpy/data/azure/` directory (legacy Azure modules) - `msticpy/data/azure_blob_storage.py` - `msticpy/data/azure_data.py` - `msticpy/data/azure_sentinel.py` - `msticpy/data/data_providers.py` - `msticpy/data/query_container.py` - `msticpy/data/query_defns.py` - `msticpy/datamodel/pivot.py` - Entire `msticpy/nbtools/` compatibility layer - Entire `msticpy/sectools/` compatibility layer (450+ lines removed) ### Visualization Cleanup - Removed `msticpy/vis/morph_charts.py` (162 lines) - Removed `msticpy/vis/timeline_pd_accessor.py` (266 lines) - Removed associated test file `tests/vis/test_morph_charts.py` ## Enhanced Functionality ### SQL to KQL Improvements - Significantly enhanced `msticpy/data/sql_to_kql.py` (139 lines modified) - Expanded test coverage in `tests/data/test_sql_to_kql.py` (300+ lines added) - Better handling of SQL parsing edge cases ### Azure ML and Synapse Tools - Modernized `msticpy/init/azure_ml_tools.py` (115 lines cleaned) - Updated `msticpy/init/azure_synapse_tools.py` for Python 3.10+ ### Data Processing - Streamlined `msticpy/data/data_obfus.py` (95 lines removed) - Enhanced process tree builders with modern type hints ## Testing and CI/CD ### GitHub Workflows - Updated `.github/workflows/python-package.yml` (38 modifications) - Removed `.github/workflows/codeql.yml` (92 lines removed - outdated configuration) ### Test Suite Updates - Removed tests for deprecated modules - Updated test fixtures and utilities in `tests/unit_test_lib.py` - Fixed compatibility issues in pivot tests ## Documentation - Updated `README.md` with current Python version requirements - Added comprehensive API documentation for new Prisma Cloud driver - Updated Sphinx configuration in `docs/source/conf.py` ## Statistics - **343 files changed** - **1,490 insertions(+)** - **5,606 deletions(-)** - **Net reduction: 4,116 lines of code removed** ## Migration Notes For users upgrading to MSticPy 3.0: 1. **Python Version**: Ensure you're using Python 3.10 or later 2. **Removed Modules**: The following deprecated modules have been removed: - `msticpy.aiagents.*` - `msticpy.sectools.*` (use `msticpy.transform.*` and `msticpy.analysis.*`) - `msticpy.nbtools.*` (use `msticpy.vis.*` and `msticpy.init.*`) - Legacy Azure module aliases (use `msticpy.data.storage.*` and `msticpy.context.azure.*`) 3. **Dependencies**: The package now has fewer dependencies due to Python 3.10+ baseline 4. **Type Hints**: Code using MSticPy's type hints may benefit from better IDE support with modern union syntax ## Related - PR #867: MSticPy 3.0 and Python 3.13 Support - Branch: `ianhelle/py313-cleanup-2025-12-08`
- Replace legacy typing imports (Union, Optional, List, Dict, etc.) with modern syntax - Convert Optional[X] to X | None (PEP 604) - Convert Union[X, Y] to X | Y (PEP 604) - Convert typing.List/Dict/Set/Tuple to list/dict/set/tuple (PEP 585) - Convert isinstance() tuple checks to use | syntax where safe - Remove unused typing imports and fix duplicate import - Auto-format all code with ruff format - All ruff checks pass Files affected: 200+ files across msticpy codebase Total fixes: 1800+ type hint modernizations Note: Some lines exceed 95 char limit (pylint C0301) - will address separately
When removing the duplicate import 'from collections.abc import Iterable as C_Iterable', I forgot to update code that was still using C_Iterable. Changed to use Iterable directly. Fixes test_context_provider[ServiceNow] failure.
f5d70d5 to
a551b5d
Compare
…m/microsoft/msticpy into ianhelle/py313-cleanup-2025-12-08
ryan-detect-dot-dev
approved these changes
Dec 18, 2025
FlorianBracq
approved these changes
Dec 31, 2025
Collaborator
FlorianBracq
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, well done!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR #867: MSticpy 3.0 and Python 3.13 Support
Important
Major Version Release - This PR introduces breaking changes. Review the migration guide before upgrading.
📋 Overview
Major version release modernizing the codebase with Python 3.13 support, development tooling improvements, and removal of deprecated features.
🎯 Key Changes
🐍 Python Version Support
Updated CI Matrix
🛠️ Development Workflow Modernization
Migrated to Ruff
Replaced multiple tools (
black,flake8,isort) with unifiedrufffor linting and formatting:Changes:
.pre-commit-config.yamland GitHub Actions workflowsRemoved dependencies:
🗑️ Deprecated Features Removed
Warning
The following features have been completely removed in v3.0
KqlMagic Integration
msticpy/__init__.pyKqlMagic configurationKqlmagicCustom[jupyter-extended]AI Agents Modules
Legacy Query Drivers
test_kql_driver.py(254 lines)test_kusto_driver.py(372 lines)Deprecated Pandas Accessors
📦 Dependencies & Configuration
importlib-resourcesmo-sql-parsing2.x→11.xipython>=7.23.1(unified)Documentation Updates
💻 Code Quality Improvements
Type Hints Modernization
Import Modernization
Additional improvements:
datetime.utcnow()→datetime.now(timezone.utc))🔧 CI/CD Updates
Simplified workflows:
black,flake8,pydocstylestepsruff checkandruff formatUsers upgrading to v3.0 should note:
mp_plotandmpaccessorsmo-sql-parsingv2 → v11 - SQL parsing behavior may differ🚀 Migration Guide
Step 1: Upgrade Python
Step 2: Update Code
Replace deprecated accessor methods:
Step 3: Update Dependencies
📊 Statistics
📚 Related Links
Reviewer Comments
@ryan-detect-dot-dev:
Resolved discussions:
Tip
Status: Open | All checks passing ✅
Ready to merge pending final approval