Skip to content

Commit 4d00241

Browse files
Copilotzkoppert
andcommitted
Fix linting issues by removing trailing whitespace and formatting blank lines
Co-authored-by: zkoppert <6935431+zkoppert@users.noreply.github.com>
1 parent b6d9a34 commit 4d00241

File tree

5 files changed

+55
-55
lines changed

5 files changed

+55
-55
lines changed

auth.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ def auth_to_github(
3434
) -> github3.GitHub:
3535
"""
3636
Establish an authenticated connection to GitHub.com or GitHub Enterprise.
37-
37+
3838
This function creates an authenticated GitHub client using either Personal Access Token
3939
or GitHub App authentication. It supports both GitHub.com and GitHub Enterprise
4040
installations.
41-
41+
4242
Authentication Priority:
4343
1. GitHub App authentication (if all app credentials are provided)
4444
2. Personal Access Token authentication (if token is provided)
45-
45+
4646
Args:
4747
token (str): The GitHub personal access token for authentication.
4848
Can be empty if using GitHub App authentication.
@@ -61,21 +61,21 @@ def auth_to_github(
6161
Returns:
6262
github3.GitHub: An authenticated GitHub client object that can be used
6363
to make API calls to GitHub.
64-
64+
6565
Raises:
6666
ValueError: If authentication fails due to:
6767
- Missing required credentials (no token or incomplete app credentials)
6868
- Unable to establish connection to GitHub
69-
69+
7070
Examples:
7171
>>> # Using Personal Access Token
72-
>>> client = auth_to_github(token="ghp_...", gh_app_id=None,
73-
... gh_app_installation_id=None,
74-
... gh_app_private_key_bytes=b"",
72+
>>> client = auth_to_github(token="ghp_...", gh_app_id=None,
73+
... gh_app_installation_id=None,
74+
... gh_app_private_key_bytes=b"",
7575
... ghe="", gh_app_enterprise_only=False)
76-
76+
7777
>>> # Using GitHub App
78-
>>> client = auth_to_github(token="", gh_app_id=12345,
78+
>>> client = auth_to_github(token="", gh_app_id=12345,
7979
... gh_app_installation_id=67890,
8080
... gh_app_private_key_bytes=private_key_bytes,
8181
... ghe="", gh_app_enterprise_only=False)
@@ -112,13 +112,13 @@ def get_github_app_installation_token(
112112
) -> str | None:
113113
"""
114114
Obtain a GitHub App Installation access token using JWT authentication.
115-
115+
116116
This function creates a JWT token using the GitHub App's private key and exchanges
117117
it for an installation access token that can be used to authenticate API requests
118118
on behalf of the installed app.
119-
119+
120120
Reference: https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation
121-
121+
122122
Args:
123123
ghe (str): The GitHub Enterprise endpoint URL (e.g., "https://github.company.com").
124124
Leave empty for GitHub.com.
@@ -132,20 +132,20 @@ def get_github_app_installation_token(
132132
Returns:
133133
str | None: The installation access token if successful, None if the request
134134
fails or if there's an error in the authentication process.
135-
135+
136136
Raises:
137137
No exceptions are raised directly, but request failures are handled gracefully
138138
and logged to the console.
139-
139+
140140
Notes:
141141
- The token has a default expiration time (typically 1 hour)
142142
- The token provides access to resources the app installation has been granted
143143
- Network errors and API failures are handled gracefully with None return
144-
144+
145145
Examples:
146146
>>> private_key = b"-----BEGIN PRIVATE KEY-----\\n...\\n-----END PRIVATE KEY-----"
147147
>>> token = get_github_app_installation_token(
148-
... ghe="",
148+
... ghe="",
149149
... gh_app_id="12345",
150150
... gh_app_private_key_bytes=private_key,
151151
... gh_app_installation_id="67890"

config.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,20 @@ def __repr__(self):
8686

8787
def get_bool_env_var(env_var_name: str, default: bool = False) -> bool:
8888
"""Get a boolean environment variable with proper type conversion.
89-
89+
9090
This function retrieves an environment variable and converts it to a boolean.
9191
Only the string "true" (case-insensitive) is considered True; all other
9292
values are considered False.
9393
9494
Args:
9595
env_var_name (str): The name of the environment variable to retrieve.
96-
default (bool, optional): The default value to return if the environment
96+
default (bool, optional): The default value to return if the environment
9797
variable is not set or is empty. Defaults to False.
9898
9999
Returns:
100100
bool: True if the environment variable is set to "true" (case-insensitive),
101101
False otherwise, or the default value if the variable is not set.
102-
102+
103103
Examples:
104104
>>> os.environ['TEST_VAR'] = 'true'
105105
>>> get_bool_env_var('TEST_VAR')
@@ -115,7 +115,7 @@ def get_bool_env_var(env_var_name: str, default: bool = False) -> bool:
115115

116116
def get_int_env_var(env_var_name: str) -> int | None:
117117
"""Get an integer environment variable with proper type conversion and validation.
118-
118+
119119
This function retrieves an environment variable and attempts to convert it to an integer.
120120
If the conversion fails or the variable is not set, it returns None.
121121
@@ -125,7 +125,7 @@ def get_int_env_var(env_var_name: str) -> int | None:
125125
Returns:
126126
int | None: The value of the environment variable as an integer, or None if
127127
the variable is not set, empty, or cannot be converted to an integer.
128-
128+
129129
Examples:
130130
>>> os.environ['PORT'] = '8080'
131131
>>> get_int_env_var('PORT')
@@ -148,41 +148,41 @@ def get_int_env_var(env_var_name: str) -> int | None:
148148
def get_env_vars(test: bool = False) -> EnvVars:
149149
"""
150150
Get and validate all environment variables required for the InnerSource measurement tool.
151-
151+
152152
This function loads environment variables from the system and an optional .env file,
153153
validates them, and returns a structured EnvVars object containing all configuration
154154
needed to run the tool.
155-
155+
156156
Args:
157157
test (bool, optional): If True, skip loading the .env file (used for testing).
158158
Defaults to False.
159-
159+
160160
Returns:
161161
EnvVars: A structured object containing all validated environment variables
162162
and configuration settings.
163-
163+
164164
Raises:
165165
ValueError: If required environment variables are missing or invalid:
166166
- Missing GitHub authentication (GH_TOKEN or GitHub App credentials)
167167
- Missing or invalid REPOSITORY format (must be "owner/repo")
168168
- Incomplete GitHub App credentials (missing ID, key, or installation ID)
169-
169+
170170
Environment Variables Required:
171171
Authentication (choose one):
172172
- GH_TOKEN: GitHub personal access token
173173
- GH_APP_ID + GH_APP_PRIVATE_KEY + GH_APP_INSTALLATION_ID: GitHub App credentials
174-
174+
175175
Repository:
176176
- REPOSITORY: Repository to analyze in "owner/repo" format
177-
177+
178178
Optional:
179179
- GH_ENTERPRISE_URL: GitHub Enterprise URL (for on-premises installations)
180180
- GITHUB_APP_ENTERPRISE_ONLY: Set to "true" for GHE-only GitHub Apps
181181
- REPORT_TITLE: Custom title for the report (default: "InnerSource Report")
182182
- OUTPUT_FILE: Output filename (default: "innersource_report.md")
183183
- RATE_LIMIT_BYPASS: Set to "true" to bypass rate limiting
184184
- CHUNK_SIZE: Number of items to process at once (default: 100, minimum: 10)
185-
185+
186186
Examples:
187187
>>> os.environ['GH_TOKEN'] = 'ghp_...'
188188
>>> os.environ['REPOSITORY'] = 'octocat/Hello-World'

markdown_helpers.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
def markdown_too_large_for_issue_body(file_path: str, max_char_count: int) -> bool:
2222
"""
2323
Check if a markdown file exceeds GitHub's issue body character limit.
24-
24+
2525
GitHub issues have a maximum character limit for the body content. This function
2626
reads a markdown file and determines if it would exceed this limit.
27-
27+
2828
Args:
2929
file_path (str): The path to the markdown file to check. Must be a valid
3030
file path that exists and is readable.
@@ -33,12 +33,12 @@ def markdown_too_large_for_issue_body(file_path: str, max_char_count: int) -> bo
3333
3434
Returns:
3535
bool: True if the file contents exceed the character limit, False otherwise.
36-
36+
3737
Raises:
3838
FileNotFoundError: If the specified file does not exist.
3939
PermissionError: If the file cannot be read due to permission issues.
4040
UnicodeDecodeError: If the file contains invalid UTF-8 encoding.
41-
41+
4242
Examples:
4343
>>> # Check if a report is too large for GitHub issues
4444
>>> is_too_large = markdown_too_large_for_issue_body("report.md", 65535)
@@ -53,11 +53,11 @@ def markdown_too_large_for_issue_body(file_path: str, max_char_count: int) -> bo
5353
def split_markdown_file(file_path: str, max_char_count: int) -> None:
5454
"""
5555
Split a large markdown file into smaller files that fit within size limits.
56-
56+
5757
This function reads a markdown file and splits it into multiple smaller files
5858
when the original file is too large for GitHub issues or other systems with
5959
character limits.
60-
60+
6161
Args:
6262
file_path (str): The path to the markdown file to split. The file must exist
6363
and be readable. The function will create new files with
@@ -67,22 +67,22 @@ def split_markdown_file(file_path: str, max_char_count: int) -> None:
6767
6868
Returns:
6969
None: This function performs file operations and creates new split files.
70-
70+
7171
Side Effects:
7272
- Creates new files with names like "{original_name}_0.md", "{original_name}_1.md", etc.
7373
- Each new file contains a portion of the original content
7474
- Files are created in the same directory as the original file
7575
- The original file is not modified or deleted
76-
76+
7777
File Naming:
7878
- Original file: "report.md"
7979
- Split files: "report_0.md", "report_1.md", "report_2.md", etc.
80-
80+
8181
Raises:
8282
FileNotFoundError: If the specified file does not exist.
8383
PermissionError: If the file cannot be read or new files cannot be created.
8484
UnicodeDecodeError: If the file contains invalid UTF-8 encoding.
85-
85+
8686
Examples:
8787
>>> # Split a large report into smaller files
8888
>>> split_markdown_file("large_report.md", 65535)

markdown_writer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ def write_to_markdown(
4343
) -> None:
4444
"""
4545
Generate a comprehensive InnerSource collaboration report in markdown format.
46-
46+
4747
This function creates a detailed markdown report that analyzes InnerSource collaboration
4848
within a repository. The report includes team ownership information, contributor
4949
analysis, and contribution statistics.
50-
50+
5151
Args:
5252
report_title (str, optional): The title to display at the top of the report.
5353
Defaults to empty string.
@@ -87,12 +87,12 @@ def write_to_markdown(
8787
8888
Returns:
8989
None: This function creates a markdown file as a side effect.
90-
90+
9191
Side Effects:
9292
- Creates a markdown file with the specified filename
9393
- Overwrites the file if it already exists
9494
- Writes UTF-8 encoded content
95-
95+
9696
Report Structure:
9797
The generated report includes the following sections:
9898
1. Report title
@@ -104,7 +104,7 @@ def write_to_markdown(
104104
7. InnerSource contributors list
105105
8. InnerSource contribution counts
106106
9. Team member contribution counts
107-
107+
108108
Examples:
109109
>>> # Generate a basic report
110110
>>> write_to_markdown(
@@ -113,7 +113,7 @@ def write_to_markdown(
113113
... innersource_ratio=0.35,
114114
... repo_data=repo_object
115115
... )
116-
116+
117117
>>> # Generate a complete report with all data
118118
>>> write_to_markdown(
119119
... report_title="Complete Analysis",

measure_innersource.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919
def evaluate_markdown_file_size(output_file: str) -> None:
2020
"""
2121
Evaluate the size of the markdown file and split it if it exceeds GitHub's issue body limits.
22-
22+
2323
This function checks if the generated markdown report is too large for GitHub issues
2424
(which have a 65,535 character limit) and splits it into multiple files if necessary.
25-
25+
2626
Args:
2727
output_file (str): The name of the output markdown file to evaluate.
2828
If empty or None, defaults to "innersource_report.md".
29-
29+
3030
Returns:
3131
None: This function performs file operations and prints status messages.
32-
32+
3333
Side Effects:
3434
- Creates additional markdown files if splitting is needed
3535
- Renames the original file to {filename}_full.md
@@ -53,7 +53,7 @@ def evaluate_markdown_file_size(output_file: str) -> None:
5353
def main(): # pragma: no cover
5454
"""
5555
Main function to run the InnerSource measurement tool.
56-
56+
5757
This function orchestrates the entire InnerSource measurement process:
5858
1. Loads environment variables and configuration
5959
2. Authenticates to GitHub (using either PAT or GitHub App)
@@ -62,19 +62,19 @@ def main(): # pragma: no cover
6262
5. Processes commits, pull requests, and issues to count contributions
6363
6. Calculates InnerSource collaboration ratios
6464
7. Generates a comprehensive markdown report
65-
65+
6666
The function uses chunked processing to handle large repositories efficiently
6767
and memory-safely.
68-
68+
6969
Returns:
7070
None: This function performs the main application logic and generates
7171
output files and console messages.
72-
72+
7373
Raises:
7474
Various exceptions may be raised during GitHub API calls, file operations,
7575
or data processing. These are generally handled gracefully with informative
7676
error messages.
77-
77+
7878
Side Effects:
7979
- Writes a markdown report to the specified output file
8080
- Prints progress messages to the console

0 commit comments

Comments
 (0)